in reply to Net::FTP troubles
As another poster mentioned, you were iterating through %Servers as a whole, which means you were trying to make connections to "1", "128.37.37.201", "2", etc. Since the first one wasn't a valid IP/hostname, the creation of your $FTP object failed (which you weren't checking for), which means your call to $FTP->login() couldn't be done since $FTP wasn't defined. Hence all of those messages.use strict; use Net::FTP; my $Local = 'c:\winnt\profiles\jlewis\desktop'; my $File = "cron.file"; my ($user, $pass) = ("username", "password"); my @servers = qw/ 128.37.37.201 128.38.38.201 128.39.39.201 /; chdir($Local) or die "$Local: $!"; foreach (@servers) { my $FTP = new Net::FTP ($_) or die "Can't connect to $_"; $FTP->login($user, $pass) or die "Can't login as $user" $FTP->ascii; $FTP->put($File) or die "Can't put $File" $FTP->quit; }
The warning about the uninitialized value came about because you were doing this: $IP="$Server{$key}" Since $key at one point was "128.37.37.201", you were trying stuff the value of that key in the hash into $IP. Since there was no key by that name (it was a value, remember), the result was undefined, hence that warning.
Hope this helps..
|
---|