我无法解决这个问题
!/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
,则工作正常
2条答案
按热度按时间hfwmuf9z1#
您将密码保存为变量
PASS
,但发送字符串PASS
作为密码;传递变量扩展:dbf7pr2w2#
我也有同样的问题--
sshfs
似乎在其他任何地方都能工作,但在expect
内部却不行。为什么会这样呢?expect
提前终止了它还是怎么了?我的
expect
代码:此命令在bash中运行得非常好,但在
expect
中使用时会静默失败,并显示“transport endpoint not connected