Command line 将switch/ini=nul添加到WinSCP命令行不起作用

Command line 将switch/ini=nul添加到WinSCP命令行不起作用,command-line,sftp,winscp,Command Line,Sftp,Winscp,我正在尝试编写一个自动脚本,使用WinSCP将文件上载到sftp。 下面的初始脚本可以正常工作 C:\Users\anh le>"C:\Program Files (x86)\WinSCP\WinSCP.exe" /command "open sftp://username:password@sftphost/" "cd /ADHOC" "put ""C:\Temp\ldg_pnv.csv""" "close" "exit" 但是当我添加了/ini=nul开关时,上传没有工作,也没有返回

我正在尝试编写一个自动脚本,使用WinSCP将文件上载到sftp。 下面的初始脚本可以正常工作

C:\Users\anh le>"C:\Program Files (x86)\WinSCP\WinSCP.exe" /command "open sftp://username:password@sftphost/" "cd /ADHOC" "put ""C:\Temp\ldg_pnv.csv""" "close" "exit"
但是当我添加了
/ini=nul
开关时,上传没有工作,也没有返回任何错误。 有人知道为什么添加交换机(顺便提一下)会导致这种情况吗

C:\Users\anh le>"C:\Program Files (x86)\WinSCP\WinSCP.exe" /ini=nul /command "open sftp://username:password@sftphost/" "cd /ADHOC" "put ""C:\Temp\ldg_pnv.csv""" "close" "exit"

不确定您想要实现什么,但实际上您使用
/ini=nul
的命令无法工作。您正在连接到SSH(SFTP)服务器,这需要一个。您的脚本不会这样做,当您使用
/ini=nul
时,WinSCP不会使用(可能)WinSCP GUI配置中的缓存主机密钥


不过,我确信WinSCP确实“返回错误”。您无法看到打印的错误,因为您没有启用日志记录(),也没有使用控制台接口(或)


完整命令可以如下所示:

C:\Users\anh le>"C:\Program Files (x86)\WinSCP\WinSCP.com" /log=C:\some\path\winscp.log /ini=nul /command "open sftp://username:password@sftphost/ -hostkey=""server_host_key""" "cd /ADHOC" "put ""C:\Temp\ldg_pnv.csv""" "close" "exit"
WinSCP GUI可以为您提供这样的功能,包括
-hostkey
开关