Link to home
Start Free TrialLog in
Avatar of perlwhite
perlwhiteFlag for United States of America

asked on

FTP change directory

Hello,
I am trying to FTP a file from one machine to another server.  However, it is unable to change the directory.  I have following so far-

my $ftp_remote_addr='abc';
my $ftp_user = 'bxyz';
my $ftp_pass ='lmn';
my $ftp_cwd_path = "";
my $ftp_put_filename= 'C:\\abc\\abc\\123.txt';
#############################################

my $ftp = Net::FTP->new($ftp_remote_addr, Debug => 0) ||
  die "Connect to $ftp_remote_addr failed: $@";
 $ftp->login($ftp_user, $ftp_pass)  or die "Cannot login ", $ftp->message;
   
 chdir("/ftproot/test/")
   or die("Can't change to dir $!\n");
#$ftp->cwd($ftp_cwd_path) or die "Cannot change working directory ", $ftp->message;
  print $ftp->pwd();


$ftp->put($ftp_put_filename) or die "Failed to transfer file ", $ftp->message;
$ftp->quit;

Error- cannot change working dorectory
for pwd- I get / as output
Please let me know where I am going wrong.

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of AlexPace
AlexPace
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gary
I don't know Perl but shouldn't you at least be using / for the folder not just a blank string
Avatar of perlwhite

ASKER

It was the root path for FTP site.  I changed it and works fine.
What do you mean It was the root path for FTP site What did you change it to?