【发布时间】:2020-02-28 21:03:27
【问题描述】:
我想自动执行以下命令,以便传递密码并继续文件传输。
#This command works well but it will require password
echo "put This_file_from_server_a.csv /TO/THIS/SERVER_B/PATH" | sftp remote@10.11.12.13
我曾尝试使用expect,以便自动/自动发送密码,但它不起作用,即
expect -c 'spawn "put This_file_from_server_a.csv /TO/THIS/SERVER_B/PATH" | sftp remote@10.11.12.13; expect "assword:"; send "THE_PASSWORD\r"; interact'
我收到错误
发送:生成 id exp4 未打开 在执行“发送“THE_PASSWORD\r””时
可能是什么问题?不考虑替代方案:如sshpass、lftp、private keys...
【问题讨论】:
-
这个人尝试使用
expect和sftp是什么 - 为什么?What could be the issue?- 你是spawn-int 命令put- 没有这样的命令。我猜你在put前面缺少echo。 -
@KamilCuk 不,它没有,我使用的服务器我的权限受到限制。它没有 SSHPASS 和 lftp
sshpass: command not foundlftp: command not found