2012-04-27 59 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()並列出哪些文件/目錄可用。