3

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 vedams@192.168.5.109:/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 user@192.168.5.109:/home/user /mnt/remote

Shell blocked and getting the same error.

Note: If I run sshpass -p vedams123 sshfs vedams@192.168.5.109:/home/user /mnt/remote, working withour any problem.

  • 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 Feb 2 '16 at 11:10
  • @zzart passwordless login (keyfiles) would work and skip the trouble of having a clear text password in a script file. – Fiximan Feb 19 '16 at 23:14
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.