【问题标题】:使用 OpenSSH sftp 在批处理文件中从 SFTP 下载文件 [关闭]
【发布时间】:2022-01-21 21:17:50
【问题描述】:
echo Connecting to ZOHO Downloding Server
::*encode the password*  
cipher /e %password%    
sftp test@192.168.1.1     
echo %Password%    
get text.exe D:/    
exit    
echo "download Finish" 

我知道脚本不正确。请帮我完成它。

【问题讨论】:

标签: windows batch-file sftp


【解决方案1】:

getexitsftp(子)命令。您的批处理文件执行sftp 并等待它退出(它不会自行执行)。并且只有在sftp退出后,它才会打印密码并尝试将get作为Windows命令执行,会失败。


您需要:

  • sftp 命令放到一个单独的脚本中,并使用-b switch 将其传递给sftp
  • 或者使用标准输入将命令提供给sftp

密码有问题。 OpenSSH sftp 无法自动接受密码。此处讨论:
"sshpass is not recognized" on Windows
my answer there 专门涵盖了sftp)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-16
    相关资源
    最近更新 更多