sub submit_output_to_web { my ( $url, $fname ) = @_; die( "Must provide filename\n" ) if ( ! $fname ); die( "Cannot find file \"$fname\"\n" ) if ( ! -f $fname ); # read in contents of file into $data my $data = ""; if ( ! open( INFILE, "<$fname" ) ) { die( "Could not open file \"$fname\"\n" ); } binmode( INFILE ); my $result = undef; 1 while ( $result = sysread( INFILE, $data, 8192, length($data) ) ); close( INFILE ); if ( ! defined($result) ) { die( "Error during read of file \"$fname\": $@\n" ); } my $code = q[ { use LWP::UserAgent; use HTTP::Request::Common; my $ua = LWP::UserAgent->new(); # setting the proxy is dependant on the method. # For HTTPS we require the Crypt::SSLeay module # to be installed # (ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd) # and we must set an environment variable $ENV{HTTPS_PROXY} = 'http://proxy.myorg.com:8080'; # setting the proxy for HTTP requires a call to # the ->proxy method $ua->proxy(['http'],'http://proxy.myorg.com:8080/'); $ua->timeout( 30 ); my $req = HTTP::Request::Common::POST( $url, Content_Type => 'form-data', Content => [ submit_button => 'submit', upload_file => [ undef, $fname, Content => $data ] ] ); my $resp = $ua->request( $req ); if ( $resp->is_success ) { return( 1 ); } else { die( "LWP error: " . $resp->status_line . "\n" ); } } ]; eval $code; if ( $@ ) { print( $@ . "\n" ); return( undef ); } return( 1 ); } # submit_output_to_web