Bash – When using expect: SSHFS Transport endpoint is not connected

bashexpectsshfs

When I run my SSHFS connection script from bash, everything works perfectly.

However, when I run the same script using the expect utility, I get the following error when I try to access the folder mount location:

Transport endpoint is not connected

Here is my expect script:

#!/usr/bin/expect -f
spawn standard_sshfs_connection_string_or_script
expect "password: "
send "my_password\r"

Q: Any Ideas?

Note:

  1. I've first already called: fusermount -u mount_location
  2. Is there something about spawn creating a new process, perhaps the sshfs process closes prematurely? (Is there any way to ensure the sshfs process stays open?)

Best Answer

I'm not sure the output of sshfs is caught in expect. This may be your problem - the script terminates without sending the password, which would cause the problem you describe.

Another possible scenario is that sshfs is actually sending you the output user@domain password:, and expect may not like it.

However, this really isn't a good way of dealing with the problem. Your password is in plain text within that script!!

Have you considered using public-key authentication? Take a look at this git example if you don't know how it works.

Related Question