gpt4 book ai didi

linux - 期待带有 sshfs 的解释器

转载 作者:太空宇宙 更新时间:2023-11-04 12:36:17 27 4
gpt4 key购买 nike

无法设法解决这个问题

!/usr/bin/expect -f
set prompt ":|#|\\\$"
set HOST "192.168.0.40"
set USER "root"
set PASS "1234"
set PATH "/rpms"
spawn "sshfs" "$USER@$HOST:$PATH" "/backup"
expect "Are you sure you want to continue connecting (yes/no)?"
send "yes\r"
expect "root@192.168.0.40's password:"
send "PASS\r"
exit

我得到的输出:

spawn sshfs root@192.168.0.40:/rpms /backup
root@192.168.0.40's password: root@debian:/rpms#

目录没有挂载:

cd /backup
-bash: cd: /backup: Transport endpoint is not connected

如果我手动尝试 sshfs root@192.168.0.40:/rpms/backup 它工作得很好

最佳答案

您将密码保存为变量PASS,但将字符串PASS 作为密码发送;传递变量扩展:

send "$PASS\r"

关于linux - 期待带有 sshfs 的解释器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41657983/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com