Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP attempt

Status
Not open for further replies.

george77

IS-IT--Management
Oct 1, 2002
3
AU
I cant get my ftp to work. I keep getting error message such as:
[tt]
C:\Perl\bin>ftpr.pl
Can't call method "login" on an undefined value at C:\Perl\bin\ftpr.pl line 5.[/tt]

The script:
[tt]
use Net::FTP;

$ftp = Net::FTP->new("myserver@here.com", Debug => 0);
$ftp->login("myname","mypassword") || die "nope:$!\n"; $ftp->cwd("/usr/home/myname");
$ftp->get("test.txt");
$ftp->quit;[/tt]


The server I am trying to get the file from is behind a firewall.
I am on a NT workstation trying to get a file off a Solaris 7 server.
 
mask @ in your address ------------ jamisar
Einfachheit ist das Resultat der Reife. (Friedrich Schiller)
Simplicity is the fruit of maturity.
 
jamisar is correct. Perl will even tell you so. Using warnings and strict would have produced the following message
Code:
Possible unintended interpolation of @here in string at ./netftp.pl line 6.
Global symbol "@here" requires explicit package name at ./netftp.pl line 6.
Execution of ./netftp.pl aborted due to compilation errors.
Also, it's a good idea to check the success of connections for sockets, db's, etc
[/code]
my $ftp = Net::FTP->new("myserver@here.com", Debug => 0);
die "Error connecting: $!" unless $ftp;
[/code]
which gives the following error message
Code:
Error connecting: Invalid argument at ./netftp.pl line 7.

jaa
 
Try this below:

[tt]
use Net::FTP;
use strict;
use warnings;

my $ftp = Net::FTP->new("servername.here.com", Debug => 0) or die "cant connect: $@\n";
$ftp->login("myname", "mypassword");
$ftp->cwd("/yourdirectorypathhere/directory");
$ftp->get("file.txt");
$ftp->quit;[/tt] =================
Bad Company Music
=================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top