I am trying to set up scripts that automatically connect a sshfs mount once I connect to a certain wifi network. My startup script looks like this:


echo "up" >> /var/log/custom-sshfs.log 
echo "$(iwgetid -r)" >> /var/log/custom-sshfs.log
echo "$IFACE" >> /var/log/custom-sshfs.log
echo "$(whoami)" >> /var/log/custom-sshfs.log

if [ "$IFACE" = "wlp2s0" ] && [ "$(iwgetid -r)" = "my-wifi" ]
echo "success" >> /var/log/custom-sshfs.log
su -c "sshfs server:/local/me /media/server" myuser >> /var/log/custom-sshfs.log
echo "Wrong wifi" >> /var/log/custom-sshfs.log

echo "test" >> /var/log/custom-sshfs.log

In my log-file I only see the output of the first 4 echo commands (the one in and after the if-else clause don't make it), so I I guess there is some error or bug in my code, but I can't figure it out.

Almost forgot: I have Linux Mint 18.2 & NetworkManager 1.2.6

closed as off-topic by waltinator, Zanna, user68186, N0rbert, Eric Carvalho May 9 '18 at 16:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – waltinator, Zanna, user68186, N0rbert, Eric Carvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Have you tried running the script with set -ex at the top? It might help you pinpoint the error. – hhoke1 Apr 30 '18 at 19:06