HI, 

I am new to this mailing list as well new to Perl and Web technology,
I am writing a script to automate upload and download a file from and to a
web server.
My first step is authenticate, where I need to send a POST request with
userId, password and Instituteid
and I will get a cookie which will contain some Id, and using that Id I need
to upload the file as Multipart/form-data, in MIME format,

I have written a script to get the cookie, but whenever I send a request I
get an error message 302 Moved Temporarily ,but the script to authenticate
is present in its location.
Could any one tell me what could be the reason.

My script to get the Cookie id is 

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Cookies;


my $ua = LWP::UserAgent->new();
my $uipwd = 'User=otc&Password=abc&Institution=xyz';

my $url = $ARGV[0];
my $request = HTTP::Request->new('POST','/cgi-bin/first.cgi');
$request->url($url);
$request->content_type('application/x-www-form-urlencoded');
$request->content_length(length($uipwd));
$request->content($uipwd);
my $res = $ua->request($request);

#$cjar = HTTP::Cookies::Netscape->new;
$cjar = HTTP::Cookies->new;
$cjar->extract_cookies($res);
$cjar->save("lwpcookies.txt");

print $request->as_string();

if ($res->is_success) {
        print $res->content;
} else {
        print $res->error_as_HTML;
}



Regards,
Nitin.

Reply via email to