Changeset 36592
- Timestamp:
- Mar 18, 2014, 12:04:49 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20130712/pstamp/scripts/pstamp_insert_request.pl
r35487 r36592 45 45 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 46 46 my $fields = can_run('fields') or (warn "Can't find fields" and $missing_tools = 1); 47 my $fhead = can_run('fhead') or (warn "Can't find fhead" and $missing_tools = 1); 47 48 48 49 if ($missing_tools) { … … 56 57 # Note that if it's a pstamp request then REQ_NAME should be defined. 57 58 # if it's a detectability query it will not have a REQ_NAME but will have a QUERY_ID 58 my $command = "echo $tmp_req_file | $fields -x 0 EXTNAME EXTVER REQ_NAME QUERY_ID"; 59 # my $command = "echo $tmp_req_file | $fields -x 0 EXTNAME EXTVER REQ_NAME QUERY_ID"; 60 my $command = "$fhead -x 0 $tmp_req_file"; 59 61 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 60 62 run(command => $command, verbose => $verbose); 61 if (0) {62 # stoopid fields doesn't set exit status to zero when it works63 63 unless ($success) { 64 64 print STDERR @$stderr_buf; 65 65 exit $error_code >> 8; 66 66 } 67 }68 67 my $output = join "", @$stdout_buf; 69 (undef, $extname, $extver, $req_name) = split " ", $output; 68 69 70 my $makehash = 0; 71 my %hash; 72 foreach my $line (split "\n", $output) { 73 chomp $line; 74 # split lines inte left and right using equals sign. left is the keyword 75 my ($key, $right) = split "=", $line; 76 # skip if there was no '=' 77 next if !$right; 78 79 $key =~ s/ //g; 80 81 # separate value from comment 82 my ($value, $comment) = split "/", $right; 83 # remove ' and space characters from key and value 84 $value =~ s/'//g; 85 $value =~ s/ //g; 86 87 # print "$key $value\n"; 88 89 # extract the values that we are looking for 90 $extname = $value if ($key eq "EXTNAME"); 91 $extver = $value if ($key eq "EXTVER"); 92 $req_name = $value if ($key eq "REQ_NAME"); 93 $req_name = $value if ($key eq "QUERY_ID"); 94 95 # optionally build hash. Duplicate keys get the last value seen 96 if ($makehash) { 97 $hash{$key} = $value; 98 } 99 } 100 101 # (undef, $extname, $extver, $req_name) = split " ", $output; 102 70 103 if (!$extname or ! (($extname eq "PS1_PS_REQUEST") or ($extname eq "MOPS_DETECTABILITY_QUERY"))) { 71 104 print STDERR "invalid request file\n"; 105 print "invalid request file\n"; 72 106 exit $PS_EXIT_DATA_ERROR; 73 107 } 108 74 109 if (!defined $req_name) { 75 110 print STDERR "invalid request file no REQ_NAME or QUERY_ID\n"; 111 print "invalid request file no REQ_NAME or QUERY_ID\n"; 112 exit $PS_EXIT_DATA_ERROR; 113 } 114 if (!defined $extver) { 115 print STDERR "invalid request file no EXTVER found\n"; 116 print "invalid request file no EXTVER found\n"; 76 117 exit $PS_EXIT_DATA_ERROR; 77 118 } … … 119 160 120 161 exit 0; 162 121 163 # Ask the database for the next web request number 122 164 sub get_webreq_num
Note:
See TracChangeset
for help on using the changeset viewer.
