4

I want to mount a remote directory and I want to automate this. So I write below script which not working properly.

#!/usr/bin/expect -f
spawn sshfs [email protected]:/home/user /mnt/remote
expect "assword:"
send "myPassword\r"

When I run the above script and if check ls /mnt/remote, it is giving below error:

ls: cannot access /mnt/remote: Transport endpoint is not connected

I used sshpass but not working:

sshpass -p myPassword sshfs [email protected]:/home/user /mnt/remote

Shell blocked and getting the same error.

Note: If I run sshpass -p vedams123 sshfs [email protected]:/home/user /mnt/remote, working withour any problem.

2
  • Same here, sshfs command on command prompt works, the same one in a bash script doesn't. If you add -f at the end of sshfs command then it works in script but stops the script from further execution.
    – zzart
    Commented Feb 2, 2016 at 11:10
  • 2
    @zzart passwordless login (keyfiles) would work and skip the trouble of having a clear text password in a script file.
    – FelixJN
    Commented Feb 19, 2016 at 23:14

1 Answer 1

0

This happens when there is a stale session in your intended target directory. You can clear the session with

fusermount -u /mnt/remote

where /mnt/remote is whichever your local mount file path is set to.

Thanks to https://unix.stackexchange.com/a/215009/28280

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .