Subversion Repositories camp_sysinfo_client_3

Rev

Rev 69 | Rev 233 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 69 Rev 197
Line 46... Line 46...
46
   print STDERR "Could not load library LWP\n";
46
   print STDERR "Could not load library LWP\n";
47
   exit 1; # error 1 means we could not find LWP
47
   exit 1; # error 1 means we could not find LWP
48
}
48
}
49
 
49
 
50
use Data::Dumper;
50
use Data::Dumper;
-
 
51
use Scalar::Util qw( looks_like_number );
51
 
52
 
52
sub urlEncode {
53
sub urlEncode {
53
   my $contents = shift;
54
   my $contents = shift;
54
   # escape report for URI
55
   # escape report for URI
55
   eval {   # let's use URI::Escape if it is installed
56
   eval {   # let's use URI::Escape if it is installed
Line 134... Line 135...
134
   if ( $$parameters{'key for serial number'} ) {
135
   if ( $$parameters{'key for serial number'} ) {
135
      $postData{ $$parameters{'key for serial number'} } = $$parameters{'serial number'};
136
      $postData{ $$parameters{'key for serial number'} } = $$parameters{'serial number'};
136
   } else {
137
   } else {
137
      return 9; # no serial number
138
      return 9; # no serial number
138
   }
139
   }
-
 
140
   if ( $$parameters{'upload_type'} ) {
-
 
141
      $postData{ 'upload_type' } = $$parameters{'upload_type'};
-
 
142
   }
-
 
143
   $postData{'filename'} = 
-
 
144
      $$parameters{'report date'} . '_' . 
-
 
145
      $$parameters{'client name'} . '_' . 
-
 
146
      $$parameters{'host name'} . '_' . 
-
 
147
      $$parameters{'serial number'} . 
-
 
148
      '.yaml';
139
   my $result = sendData( $url, \%postData );
149
   my $result = sendData( $url, \%postData );
140
   if ( $result ) { # we got a response, so validate the transfer
150
   if ( $result->is_success ) { # we got a response, so validate the transfer
141
      #print $result->content . "\n";
151
      #print $result->status_line . "\n"; die;
142
      unless ( ( $result->content * 1) == length($message) ) { # report returned was not one we sent
152
      #unless ( ! looks_like_number( $result->content ) && ( $result->content * 1) == length($message) ) { # report returned was not one we sent
143
         print STDERR "Server did not read file correctly\nWe sent " . length($message) . " bytes but server only saved $result->content\n";
153
      #   print STDERR "Server did not read file correctly\nWe sent " . length($message) . " bytes but server only saved " . $result->content . "\n";
144
         return 3;
154
      #   return 3;
145
      } 
155
      #} 
146
   } else {
156
   } else {
147
      print STDERR "URL did not work. Full URI sent follows\n$url\n";
157
      print STDERR "URL did not work. Full URI sent follows\n$url\n";
-
 
158
      print STDERR "Return was " . $result->content . "\n";
148
      return 4; # crud, could not even find the URL
159
      return 4; # crud, could not even find the URL
149
   }
160
   }
150
   `rm $saveFileName`;
161
   `rm $saveFileName`;
151
   return 1;
162
   return 1;
152
}
163
}