Re: Posting files to a secure site
sdavis35@csc.com
Thu, 18 Jan 2001 08:49:55 -0500
I get the following error message:
Can't call method "request" on an undefined value at /usr/local/lib/perl5/site_perl/5.005/LWP/UserAgent.pm line 227.
The part that confuses me is "[ filename => 'FILE' ];"... if I don't know of a cgi script on
the secure server, how do I know what to name the variable (or does that matter?)... and
how do I get it to post the actual file so it can be retrieved. Is this the right code to use?
I have successfully performed a GET to this site so I believe everything is installed correctly.
I am running this on a Unix box and here is the code I ran:
Thanks for any help.
#!/usr/local/bin/perl -w
use LWP::Simple;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$user_agent = LWP::UserAgent->new;
$request = POST 'https://URL',
[ filename => 'FILE' ];
$request->authorization_basic("username","password");
$request->content_type('application/x-www-form-urlencoded');
$response=$user_agent->request($request);
print $response->as_string;
cuyan@asu.edu on 01/17/2001 05:30:50 PM
To: Samantha J Davis/CEG/CSC@CSC
cc: libwww@perl.org
Subject: Re: Posting files to a secure site
What do you mean when you say " not fulfilling my needs" ? Does it actually
return something , and you don't like what you see? Or does it not return
anything other than an error msg?
cenk
On Wed, 17 Jan 2001 sdavis35@csc.com wrote:
> I need to post text files to a secure web site. All the information I
have
> is the following:
>
> URL (https://some URL)
> the username
> the password
>
> I have been messing around with the following sample code that I found...
> but it doesn't seem to be fulfilling my needs since I don't know of any
cgi
> script on the server side. Is there information I am missing that is
> necessary for me to post text files to this site? Can anyone point me to
> sample code that will help me?
>
>
> use LWP::Simple;
> use URI::URL;
> use HTTP::Request::Common qw(POST);
> use LWP::UserAgent;
> $ua = LWP::UserAgent->new(); #create a user agent
> #post the message to the server
> #this will activate the program that needs to run
> #in this program, reciever.pl will run on the server side
> $streamstring = "string to be passed to the server";
> my $req = POST 'http://3.212.228.149/cgi-bin/reciever.pl',[Filecontents
=>$streamstring];
> $req->content_type('application/x-www-form-urlencoded');
> $req->content('match=www&errors=0');
> #content is what the server sends back after processing
> $content = $ua->request($req)->as_string;
> print $content;
>
> Thanks,
> Sammy Davis
>
>