Subversion Repositories camp_sysinfo_client_3

Rev

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

Rev 197 Rev 233
Line 1... Line 1...
1
#! /usr/bin/env perl
1
#! /usr/bin/env perl
2
 
2
 
3
#    Program: upload_http.pl
3
#    Program: upload_http
4
#    Copyright (C) 2016  R. W. Rodolico
4
#    Copyright (C) 2016  R. W. Rodolico
5
#
5
#
6
#    Description
6
#    Description
7
#      Script will upload file passed on STDIN to URL defined in $server
7
#      Script will upload file passed on STDIN to URL defined in $server
8
#      using variable name $urlVarName.
8
#      using variable name $urlVarName.
Line 31... Line 31...
31
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
#    GNU General Public License for more details.
32
#    GNU General Public License for more details.
33
#
33
#
34
#    You should have received a copy of the GNU General Public License
34
#    You should have received a copy of the GNU General Public License
35
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
35
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 
36
#
-
 
37
# version 1.1 RWR, 20240518
-
 
38
# Setting up so only UTF8 sent
36
 
39
 
37
use warnings;
40
use warnings;
38
use strict;
41
use strict;
-
 
42
use open ':std', ':encoding(utf8)' ; # force all I/O, including disk and STD?, to use utf-8
39
 
43
 
40
our $VERSION = '1.0';
44
our $VERSION = '1.1';
41
 
45
 
42
eval {
46
eval {
43
   use LWP;
47
   use LWP;
44
};
48
};
45
if ( $@ ) {
49
if ( $@ ) {
Line 109... Line 113...
109
      &writeFile( $saveFileName, $message ); # make a backup copy of the report
113
      &writeFile( $saveFileName, $message ); # make a backup copy of the report
110
      $postData{ $$parameters{'key for report'} } =  
114
      $postData{ $$parameters{'key for report'} } =  
111
                              [ #'/tmp/theReport' => 'myReport'
115
                              [ #'/tmp/theReport' => 'myReport'
112
                                 undef,
116
                                 undef,
113
                                 'temp.report',
117
                                 'temp.report',
114
                                 'Content-Type' => 'application/text',
118
                                 'Content-Type' => 'application/yaml; charset=UTF-8',
115
                                 'Content' => $message
119
                                 'Content' => $message
116
                              ];
120
                              ];
117
   } else {
121
   } else {
118
      return 5; # no key given for report
122
      return 5; # no key given for report
119
   }
123
   }
Line 144... Line 148...
144
      $$parameters{'report date'} . '_' . 
148
      $$parameters{'report date'} . '_' . 
145
      $$parameters{'client name'} . '_' . 
149
      $$parameters{'client name'} . '_' . 
146
      $$parameters{'host name'} . '_' . 
150
      $$parameters{'host name'} . '_' . 
147
      $$parameters{'serial number'} . 
151
      $$parameters{'serial number'} . 
148
      '.yaml';
152
      '.yaml';
-
 
153
   print Dumper( \%postData ); die;
149
   my $result = sendData( $url, \%postData );
154
   my $result = sendData( $url, \%postData );
150
   if ( $result->is_success ) { # we got a response, so validate the transfer
155
   if ( $result->is_success ) { # we got a response, so validate the transfer
151
      #print $result->status_line . "\n"; die;
156
      #print $result->status_line . "\n"; die;
152
      #unless ( ! looks_like_number( $result->content ) && ( $result->content * 1) == length($message) ) { # report returned was not one we sent
157
      #unless ( ! looks_like_number( $result->content ) && ( $result->content * 1) == length($message) ) { # report returned was not one we sent
153
      #   print STDERR "Server did not read file correctly\nWe sent " . length($message) . " bytes but server only saved " . $result->content . "\n";
158
      #   print STDERR "Server did not read file correctly\nWe sent " . length($message) . " bytes but server only saved " . $result->content . "\n";