2017-05-25 298 views
0

我想创建一个脚本,它将一个目录的内容复制到FTP位置,但是我尝试过的每个示例都失败了。我需要这个目标FTP站点内的文件夹任何人都可以指向正确的方向。FTP脚本失败

谢谢

批处理文件如下。

@ftp -i -s:"%~f0"&GOTO:EOF 
open 0.0.0.0 
[email protected] 
Pa55word 
!:--- FTP commands below here --- 
lcd c:\program files\system\location 
cd storage 
binary 
mput "*.*" 
disconnect 
bye 
+0

你看到了什么错误信息? – criticalfix

+0

我没有收到错误消息,它只是没有复制任何东西。 – MartynTheHub

+0

如果您有权访问日志文件,那么可能值得追求这些文件。 – criticalfix

回答

0

一旦FTP打开,您不再处于命令提示符下。你在FTP里面。在以下示例中,您需要使用批处理文件编写ftp脚本FTPInstructions.ftp。然后打开ftp,告诉它运行脚本。

当您调用ftp.exe程序从批处理文件运行ftp脚本时,您可以将ftp.exe控制台输出重定向到日志文件并检查该日志文件是否有错误。你需要重定向stdout和stderr。事情是这样的:

echo open 0.0.0.0>FTPInstructions.ftp 
echo user UserName>>FTPInstructions.ftp 
echo Password>>FTPInstructions.ftp 

echo something>>FTPInstructions.ftp 
echo something else>>FTPInstructions.ftp 
. 
. 
echo bye>>FTPInstructions.ftp 

ftp.exe -n -s:FTPInstructions.ftp>FTPSession.log 2>&1 

然后,您可以在FTPSession.log文件中使用查找或FINDSTR在批处理文件中找到任何错误信息输出通过Ftp.exe的。