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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Net::FTP

Status
Not open for further replies.

kturner

Programmer
Mar 6, 2001
5
US
I can't get my script to ftp.
I have a feeling it is network/socket/protocol stuff. ( I don't know much about communciations, as is apparent.)
Can anyone help?
Here's the code.

--------------------------------------------
#!/usr/sbin/perl -w

use Net::FTP;

$host = "123.45.678.912";
$user = "name";
$pass = "passwdname";
$home = "/home/httpd/htdocs";
$file = "newindex.html";

$ftp = Net::FTP->new("hpsab8");
die "Could not connect: $!" unless $ftp;
$ftp->login($user, $pass);

$ftp->cwd($home);

$ftp->get($file);
$ftp->quit;

------------------------------
Here's the error message:

Use of uninitialized value at /usr/share/lib/Perl5/Net/FTP.pm line 1039
Use of uninitialized value at /usr/share/lib/Perl5/Net/Cmd.pm line 307
Argument "" isn't numeric in ne at /usr/share/lib/perl5/Net/FTP.pm line 1024
Could not connect: Bad file number at myftp.pl line 14

-----------------------------------------

Thanks for any and all help.

Kyle


 
Correction.

Could not connect: Bad file number at myftp.pl line 12.

Whatever the case I beieve its at:

$ftp->login($user, $pass);

Thanks again.
Kyle
 
it looks more like you're miscalling 'new'. the first argument is the host name. you had prepared the variable '$host', but then you never used it. instead, you used "hpsab8", and that doesn't look like what you had intended. try changing that part to the variable. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Thanks for the help.

I made the changes, but I still get the same errors.
BTW, I checked to make sure the logon and password and filename were all correct. OK.

 
your code looks ok to me actually, I would have written

$ftp = Net::FTP->new("hpsab8") ||
die "Could not connect: $!" unless $ftp;

but yours should work as well Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
hmm. got me. is there a firewall inbetween you and the ftp server? are you using the most recent version of Net::FTP? it says 'Could not connect: bad file number', so it may not even be getting in. try setting the debug level of ftp to 1, you might get more info from it that way.
sorry. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top