arm has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have following code, and wondering why is it not changing directroy on remote server. The directory on the server exists. Please advise.

use strict; use warnings; use File::Copy; use Net::FTP; use Net::FTP::File; use Cwd; use Win32; my $ftp_remote_addr='server'; my $ftp_user = 'login'; my $ftp_pass ='pass'; my $ftp_cwd_path = ""; my $ftp_put_filename= 'C:\\ftp\\a\\move\\test.txt'; ############################################# my $ftp = Net::FTP->new($ftp_remote_addr,Timeout => 60, Debug => 0) || die "Connect to $ftp_remote_addr failed: $@"; $ftp->login($ftp_user, $ftp_pass) or die "Cannot login ", $ftp->mess +age; my $dir = '/ftp/agc/move'; $ftp->cwd($dir) or die "Can't cwd to $dir\n"; $ftp->message; $ftp->put($ftp_put_filename) or die "Failed to transfer file ", $f +tp->message; $ftp->quit;

Error- cannot cwd

thanks

Replies are listed 'Best First'.
Re: FTP CWD not working
by wink (Scribe) on Sep 27, 2013 at 17:24 UTC

    Have you tried logging into the server on the command line and changing to that directory? Is it maybe a permissions problem?

    Also worth nothing that in your current code, $ftp->message will never be printed. You should change that semicolon to a comma.

    $ftp->cwd($dir) or die "Can't cwd to $dir\n", $ftp->message;
Re: FTP CWD not working
by Laurent_R (Canon) on Sep 27, 2013 at 17:30 UTC

    The strange thing is that the error message you report is not the same as the one you have in your code, as if your program did not even have time to print out the dieing message.