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 also 2

Status
Not open for further replies.

sleuth

Programmer
Jan 12, 2001
134
US

Hey Mates,

Ok, so like I said, I'm working on this script, I'm trying to transfer files between my servers and local machines. I'm not in doubt that this will be easily done, but I am having trouble testing my install of the module, and the documentation isn't helping.

THe code I'm using is this:

print "Content-type: text/html\n\n";
$host = "IP Address";
use Net::FTP;
$ftp = Net::FTP->new("$host", Debug => 0);
$ftp->login("name",'pass');
# $ftp->cwd("/pub");
# $ftp->get("that.file");
$ftp->ls("/home/path/dir");
$ftp->quit;

print "test";

I'm on a windows maching with this, local pc.

Ok, so after I did this and got passed the login errors I was getting I finally saw "test" on my screen, telling me the module installed ok, I think. So now I'm trying to get that

$ftp->ls("/home/path/dir");

Line to work, it says in the documentation that it stores it into an array or scalar, but I tried

print $_; and print @_; but they were undefined, so how can I get the out put from

$ftp->ls("/home/path/dir");

Thanks,

Tony
 
the calls to ftp return an array. they don't automatically set it to anything, you need to do that:[tt]
my @array = $ftp->ls("/what/ever/path/");
print(join(" ", @array));[/tt]

or even skip the assignment, and print out the call to ftp:[tt]
$, = " ";
print $ftp->ls("/blah/blah/blah/");[/tt]



(note: '$,' is the variable for output field separator, which is usually nothing. it determins what is printed inbetween each entry in the list supplied to print. it's just a round-about way of doing the 'print(join())' i had in the first statement :) ) "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
There are a lot of life savers in the forums,

Thanks a lot Mate, I can't even begin to express my gratitude, I'm going to go play with my new code now :)

Tony

"Voting Is Cool, Huh Huh"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top