Search code examples
python-3.xlinux-mintpexpect

sshfs with pexpect reported no error but failed to mount (Python 3)


I ask for help!

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) 

Runs without error, but /home/user/Mnt/ is empty. I run the code on Linux Mint 20.1.


Solution

  • sshfs should have been killed by SIGHUP prematurely.

    Try ignoring SIGHUP like this:

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