mchiles has asked for the wisdom of the Perl Monks concerning the following question:
O wise ones and those seeking wisdom...
I have been trying for a couple of weeks now to get the put function working in a subscript using Net::FTP. Here is the code:
use Net::FTP; my $ftp; $ftp = Net::FTP->new($ftp_server, Debug => 1)or die "Cannot connect"; $ftp->login($login,$password)or die $ftp->message; $ftp->pwd or die $ftp->message; $ftp->cwd($upload_to_dir) or die $ftp->message; warn "Failed to set binary mode\n" unless $ftp->binary(); print "Uploading $input_file...<br>"; $ftp->put ( $input_file, $new_file_name ) or die "did not upload"; $ftp->quit;
The file never uploads at the $ftp->put line - there is only death.
My first guess is that the file path is formatted wrong for the $input_file variable. My current value and format is:
e:\test\picture.jpg
I have also tried
e:/test/picture.jpg
e://test//picture.jpg
E://test//picture.jpg
and a variety of other such things but I haven't got it to work. Does anyone know what the correct format for a path for that arguement should be?
Do I need to somehow direct the script to a specific directory on the local computer first (similar to how $ftp->cwd() is used to get to the proper directory on the remote host)?
My value for $new_file_name is test.jpg.
I have tested other things such as creating a directory using this script and I can do that, so I believe I am correctly logged in by FTP and in the proper directory.
I have talked to my host to see that Net::FTP is correctly installed and they assure me that it is, and even reinstalled it to be sure. I have the log of that re-installation if anyone things it would be useful.
I noticed on my server in the list of Installed Perl Modules that there appears to be two copies of Net::FTP - could that be causing my problem, if one is defective??? If that is the case, how do we remove one?
Could it be that the Net::FTP program is not compatible with my server (basic Linux) or its firewall? I seem to have no trouble ftping with the same username and password via ws_ftp pro.
Your insight and wisdom is greatly appreciated!
-Matt :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Struggles with Put in Net::FTP
by jaa (Friar) on May 25, 2004 at 18:14 UTC | |
by Anonymous Monk on May 25, 2004 at 18:26 UTC | |
by mchiles (Initiate) on May 25, 2004 at 22:25 UTC | |
by castaway (Parson) on May 26, 2004 at 05:33 UTC | |
by mchiles (Initiate) on May 26, 2004 at 15:19 UTC | |
by nimdokk (Vicar) on May 26, 2004 at 16:40 UTC | |
by castaway (Parson) on May 26, 2004 at 19:46 UTC | |
| |
|
Re: Struggles with Put in Net::FTP
by nimdokk (Vicar) on May 25, 2004 at 17:53 UTC | |
by mchiles (Initiate) on May 25, 2004 at 22:42 UTC | |
by nimdokk (Vicar) on May 26, 2004 at 10:29 UTC | |
by mchiles (Initiate) on May 26, 2004 at 15:43 UTC | |
|
Re: Struggles with Put in Net::FTP
by vek (Prior) on May 25, 2004 at 21:40 UTC | |
by mchiles (Initiate) on May 25, 2004 at 22:57 UTC |