Here is another post on yout tube !!!
http://www.nytimes.com/2006/10/12/technology/12tube.html?th&emc=th
Tuesday, October 17, 2006
Monday, October 16, 2006
Sunday, October 01, 2006
upload file to https server using perl
... had some trouble initially to post / upload a file to https server
but using lwp::useragent it was easy ..
here is my code
#!/usr/bin/perl
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Cookies;
my $https_login = 'https://192.168.1.3';
my $https_post = 'https://192.168.1.3/upload';
my $https_user = 'xxxxx';
my $https_pass = 'yyyyy';
&postHTTPS();
sub postHTTPS
{
#secure login
my $ua = LWP::UserAgent->new();
$ua->protocols_allowed( [ 'https'] );
$ua->cookie_jar(HTTP::Cookies->new(file =>
".cookies.txt",autosave => 1));
my $response = $ua->post($https_login, [ 'user' =>
"$https_user",'password' => "$https_pass" ] );
#print Dumper($response);
if ($response->is_error())
{
printf " %s\n", $response->status_line;
print "https request error!\n";
} else {
my $content = $response->content();
print "$content\n";
}
$response = $ua->post($https_post, [
filename =>['/tmp/abc.txt'],
], );
if ($response->is_error())
{
printf " %s\n", $response->status_line;
print "https request error!\n";
} else {
my $content = $response->content();
print "$content\n";
}
but using lwp::useragent it was easy ..
here is my code
#!/usr/bin/perl
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Cookies;
my $https_login = 'https://192.168.1.3';
my $https_post = 'https://192.168.1.3/upload';
my $https_user = 'xxxxx';
my $https_pass = 'yyyyy';
&postHTTPS();
sub postHTTPS
{
#secure login
my $ua = LWP::UserAgent->new();
$ua->protocols_allowed( [ 'https'] );
$ua->cookie_jar(HTTP::Cookies->new(file =>
".cookies.txt",autosave => 1));
my $response = $ua->post($https_login, [ 'user' =>
"$https_user",'password' => "$https_pass" ] );
#print Dumper($response);
if ($response->is_error())
{
printf " %s\n", $response->status_line;
print "https request error!\n";
} else {
my $content = $response->content();
print "$content\n";
}
$response = $ua->post($https_post, [
filename =>['/tmp/abc.txt'],
], );
if ($response->is_error())
{
printf " %s\n", $response->status_line;
print "https request error!\n";
} else {
my $content = $response->content();
print "$content\n";
}
Subscribe to:
Posts (Atom)