I have been using FTP to move files to a remote site manually and since the number of files has been growing, I thought I would write a PERL script to make my life easier.
I'm on an Windows XP machine. My script connects to the remote host, logs in, and changes directories just fine - however it fails trying to do a "dir", "get" or "put". Here's the part that works:
Code:
$ftp = Net::FTP->new($target) or die "Cannot Connect ", $! ;
$ftp->login($usr,$pwd) or die "Cannot Login ", $! ;
$ftp->cwd($tdir) or die "Cannot change directory", $! ;
Then I tried the following:
Code:
@rdir = $ftp->dir() or die "Cannot do Dir - ", $! ;
and recieved the following error message
Quote:
|
Cannot do Dir - Bad file descriptor at C:\...\ftp4.pl line 23. |
So I tried to get a file that I knew was in that directory, and I included calls to mdtm and size to make sure that everything was where I expected:
Code:
$mdate = $ftp->mdtm("index.html") or die "Cannot get mod date - ", $! ;
$isize = $ftp->size("index.html") or die "Cannot get size - ", $! ;
print "\nIndex.html " ;
print "\n size : $isize" ;
print "\n mod : $mdate" ;
print "\n\n" ;
$rfil = $ftp->get("index.html","getindex.html") or die "cannot get file - ", $! ;
and I got the following
Quote:
Index.html
size : 221
mod : 1075246992
cannot get file - Bad file descriptor at C:\...\ftp4.pl line 35. |
I'm at a loss as to how come I can manually FTP, I can use Net::FTP to connect and login to the remote server - but I can't seem to do anything useful like "get" or "dir"?
Thanks in advance for any help.