[Israel.pm] Downloading using LWP

Berler Chanan chananb at centerity.com
Wed Feb 18 01:06:17 PST 2009

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?

use LWP 5.64;
&download_plugin('check_snmp', 'admin', 'admin', '');

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;
    my $lv_browser = LWP::UserAgent->new;
          '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";
    if ($lv_response->is_success) 
      print FILE $lv_response->content;  # or whatever
    else {
       die $lv_response->status_line;
    close FILE;

More information about the Perl mailing list