2012-04-27 58 views
2

在问候我以前张贴的question,我写了下面的脚本加载一个特定的文件:中获取文件 - 的Perl/Unix的

#!/bin/perl 

use strict; 
use Net::FTP; 

my $ftpOb = Net::FTP->new("X") 
     or die ("Could not connect to the FTP Server: [email protected]"); 
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:/

任何人都可以请帮我调试这里的问题?

回答

2

在您的错误消息中包含$ftpOb->message()(连接除外,其中[email protected]是正确的错误消息)。

也做一个dir()并列出哪些文件/目录可用。