首页 > 解决方案 > 带有 pexpect 的 sshfs 没有报告错误但无法挂载(Python 3)

问题描述

我寻求帮助!

command = "sshfs " + username + "@" + host + ":" + hostdirectory \
        + " " + mountpoint + " -o nonempty "
 
sshfs = pexpect.spawn(command)
sshfs.expect(username + "@" + host + "'s password: ")
time.sleep(1)
sshfs.sendline(password)
time.sleep(10)
sshfs.expect(pexpect.EOF) 

运行没有错误,但/home/user/Mnt/为空。我在 Linux Mint 20.1 上运行代码。

标签: python-3.xlinux-mintpexpect

解决方案


sshfs应该被SIGHUP过早地杀死。

尝试SIGHUP像这样忽略:

command = "sshfs " + ...
pexpect.spawn('bash', args=['-c', "trap '' HUP; " + command])
...

推荐阅读