I execute a script like ./script.sh
with one parameter: ./script.sh on
.
This tells a script to turn my light off or on depending on the value of the parameter.
I use this case statement for this:
#!/bin/bash
case "$1" in
on) sudo something
;;
off) sudo something
;;
esac
exit 0
Now, I want to give another parameter, for the location of my lights. It is not of importance now how this works with the light switching, I want to make another case statement in the on)
and off)
cases.
I tried this, but that does not work:
#!/bin/bash
case "$1" in
on)
case "$2" in
kitchen) sudo something
;;
garage) sudo something
;;
esac
;;
off)
case "$2" in
kitchen) sudo something
;;
garage) sudo something
;;
esac
;;
esac
exit 0
I am completely not familiar with UNIX, I manage to follow some tutorial but that's it. Any help is appreciated! Also, a whole other case structure, like checking two parameteres at the same time would be great, anything that works helps! :)
Also, I am sorry if this is the wrong StackExchange community, please let me know and I'll move it to another!
P.S. I am using Raspbian (on Raspberry Pi)