2

关于我之前发布的问题,我编写了以下脚本来加载特定文件:

#!/bin/perl

use strict;
use Net::FTP;

my $ftpOb = Net::FTP->new("X")
         or die ("Could not connect to the FTP Server: $@");
print "Connected \n";

$ftpOb->login("A", "B")
         or die ("Incorrect server credentials");
print "Logged in \n";

print " Current folder is: " . $ftpOb->pwd();

$ftpOb->cwd("root/Folder") or die ("Cannot connect to the folder on Server");
print "Transferred to folder \n";


$ftpOb->get("621418185-006249189002-5383.txt")
         or die ("Error occured while fetching the file");

$ftpOb->quit;

但是,代码似乎无法更改工作目录,我得到以下输出:

Connected
Logged in
Cannot connect to the folder on Server at ./GetUploadFile.pl line 16.
 Current folder is: /

谁能帮我在这里调试问题?

4

1 回答 1

2

Include $ftpOb->message() in your error messages (except for the connect, where $@ is the correct error message).

Also do a dir() and list what files/directories are available.

于 2012-04-27T20:15:14.627 回答