[Israel.pm] Downloading using LWP

Avishalom Shalit avishalom at gmail.com
Wed Feb 18 02:35:37 PST 2009


when you say "doesn't work"
what happens ?
did you try passing a $lv_plugun as a simple filename with no directory path ?

2009/2/18 Berler Chanan <chananb at centerity.com>:
> Hi All,
>
> This is a small LWP utility I wrote:
> It works fine using Windows, but it doesn't work when I try to download a
> file into unix, does anyone knows what I did wrong?
> Thanks
> Chanan
>
> use LWP 5.64;
> &download_plugin('check_snmp', 'admin', 'admin', '192.168.111.9');
>
> sub download_plugin
> {
>    my ($lv_plugin, $lv_user, $lv_pass, $lv_host, $lv_path, $lv_port) = @_;
>
>        $lv_port = 80 unless ($lv_port);
>        $lv_path = '/docs/' unless ($lv_path);
>
>        $lv_host .= ":" . $lv_port unless ($lv_host =~ /:/);
>        print $lv_host;
>        exit;
>
>    my $lv_browser = LWP::UserAgent->new;
>    $lv_browser->credentials(
>                  $lv_host,
>          'Monitor Server',
>                  $lv_user => $lv_pass
>    );
>    my $lv_url = "http://$lv_{host}$lv_{path}/$lv_plugin";
>
>    my $lv_response = $lv_browser->get($lv_url);
>    open FILE, ">$lv_plugin";
>    binmode(FILE);
>    if ($lv_response->is_success)
>    {
>      print FILE $lv_response->content;  # or whatever
>    }
>    else {
>       die $lv_response->status_line;
>    }
>    close FILE;
> }
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>



-- 
-- vish



More information about the Perl mailing list