Shell script for network manager not completing [closed]
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
bash scripts network-manager sh
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
add a comment |Â
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
bash scripts network-manager sh
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
Have you tried running the script withset -ex
at the top? It might help you pinpoint the error.
â hhoke1
Apr 30 at 19:06
add a comment |Â
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
bash scripts network-manager sh
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
bash scripts network-manager sh
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
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
Have you tried running the script withset -ex
at the top? It might help you pinpoint the error.
â hhoke1
Apr 30 at 19:06
add a comment |Â
Have you tried running the script withset -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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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