无法执行sftp批处理文件

无法执行sftp批处理文件,ftp,sftp,Ftp,Sftp,我有一个windows批处理文件要从服务器a(windows)连接到 服务器B(UNIX)通过sftp获取文件。脚本如下: sftpg3 -oStrictHostKeyChecking=no -oIdentityFile=EAPIINSTADM_hostnameA ftpeapsg@hostnameB lcd D:\APPBASE\EAPSG\GEMSSG get GENUOBGW1 /sftp/ftphrssg/HRSSG/EAPSG exit 当我运行脚本时,它会在运行第一行后停止,即sf

我有一个windows批处理文件要从服务器a(windows)连接到 服务器B(UNIX)通过sftp获取文件。脚本如下:

sftpg3 -oStrictHostKeyChecking=no -oIdentityFile=EAPIINSTADM_hostnameA ftpeapsg@hostnameB
lcd D:\APPBASE\EAPSG\GEMSSG
get GENUOBGW1 /sftp/ftphrssg/HRSSG/EAPSG
exit
当我运行脚本时,它会在运行第一行后停止,即sftpg3-oStrictHostKeyChecking=no

D:\APPBASE\EAPSG\GEMSSG>sftpg3 -oStrictHostKeyChecking=no -oIdentityFile=EAPIINSTADM_hostnameA ftpeapsg@hostnameB
Warning: ignoring unsupported option -o
Warning: ignoring unsupported option -o
Remote system type is POSIX.
sftp>
它没有在下面几行执行:

lcd D:\APPBASE\EAPSG\GEMSSG
get GENUOBGW1 /sftp/ftphrssg/HRSSG/EAPSG
如果我一次手动运行一行命令,它就会工作

你知道为什么脚本不能完全运行吗


谢谢。

这是因为sftpg3是一个类似于sftp的客户端,它会提示与等待输入的服务器进行交互会话。因此,脚本中的第一行只是打开会话并等待该命令(即打开的提示符)退出。您需要将输入重定向到提示的会话中(在unix中,如使用