Shell script for network manager not completing [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












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:



#!/bin/sh

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" ]
then
echo "success" >> /var/log/custom-sshfs.log
su -c "sshfs server:/local/me /media/server" myuser >> /var/log/custom-sshfs.log
else
echo "Wrong wifi" >> /var/log/custom-sshfs.log
fi

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







share|improve this question














closed as off-topic by waltinator, Zanna, user68186, N0rbert, Eric Carvalho May 9 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 at 19:06















up vote
1
down vote

favorite












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:



#!/bin/sh

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" ]
then
echo "success" >> /var/log/custom-sshfs.log
su -c "sshfs server:/local/me /media/server" myuser >> /var/log/custom-sshfs.log
else
echo "Wrong wifi" >> /var/log/custom-sshfs.log
fi

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







share|improve this question














closed as off-topic by waltinator, Zanna, user68186, N0rbert, Eric Carvalho May 9 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 at 19:06













up vote
1
down vote

favorite









up vote
1
down vote

favorite











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:



#!/bin/sh

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" ]
then
echo "success" >> /var/log/custom-sshfs.log
su -c "sshfs server:/local/me /media/server" myuser >> /var/log/custom-sshfs.log
else
echo "Wrong wifi" >> /var/log/custom-sshfs.log
fi

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







share|improve this question














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:



#!/bin/sh

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" ]
then
echo "success" >> /var/log/custom-sshfs.log
su -c "sshfs server:/local/me /media/server" myuser >> /var/log/custom-sshfs.log
else
echo "Wrong wifi" >> /var/log/custom-sshfs.log
fi

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









share|improve this question













share|improve this question




share|improve this question








edited Apr 30 at 18:15

























asked Apr 30 at 18:09









Nicolai

1064




1064




closed as off-topic by waltinator, Zanna, user68186, N0rbert, Eric Carvalho May 9 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.




closed as off-topic by waltinator, Zanna, user68186, N0rbert, Eric Carvalho May 9 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 at 19:06

















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
















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





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
















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

GRUB: Fatal! inconsistent data read from (0x84) 0+xxxxxx

`kcmshell` modules relation with `/usr/share/applications`

How to enroll fingerprints to Ubuntu 17.10 with VFS491