如何保存 Windows 内部 FTP 客户端的输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/181791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how can I save the output of windows internal FTP client?
提问by Denes Tarjan
UPDATED: on win2k it seems it works OK. Sorry for the confusion.
更新:在 win2k 上它似乎工作正常。对困惑感到抱歉。
MS Windows Vista internal ftp client has a strange behavior. When redirecting its output and error to a file, the errors do not show up there:
MS Windows Vista 内部 ftp 客户端有一个奇怪的行为。将其输出和错误重定向到文件时,错误不会显示在那里:
ftp -n -s:commands.txt host >output.log 2>&1
ftp -n -s:commands.txt 主机 >output.log 2>&1
When running it from Task Scheduler inside a batch file, I don't get any error messages if connection refused. Even if echo is on or with the -d option. Do you have a workaround for it?
从批处理文件中的任务计划程序运行它时,如果连接被拒绝,我不会收到任何错误消息。即使 echo 打开或使用 -d 选项。你有解决方法吗?
回答by Keng
have you tried it without the "2>&1"? we do this all the time but in this format
你试过没有“2>&1”吗?我们一直这样做,但以这种格式
ftp -s:FTPCMD.FTP > R:\foo\bar\FTPGET.LOG
回答by Eric Tuttleman
Not sure what's happening to you. I'd check the batch file that's running it, or maybe how you're scheduling the job.
不知道你怎么了。我会检查运行它的批处理文件,或者你是如何安排工作的。
The output is confusing as the error seems out of order, but redirecting stderr seems to work on my XP machine:
输出令人困惑,因为错误似乎无序,但重定向 stderr 似乎在我的 XP 机器上工作:
C:\Temp>ftp -s:ftpcmds.txt ftp.microsxoft.com >ftplog.txt 2>&1
C:\Temp>type ftplog.txt
ftp> Not connected.
ftp> USER sconners
Invalid command.
ftp> PASS skynet.com
Not connected.
ftp> PUT test.txt test1.txt
BYE
> ftp: connect :Unknown error number
C:\Temp>