First of all, I can make basic use of the linux command line, but have slim to none experience with shell scripting.
What I want to do: I have a router running OpenWRT, a destop pc and an Android phone. When the phone connects to the wifi, I want the router to wake-on-lan my pc.
I have a vague idea on how to do this but need a little help on putting the pieces together:
- run a script with crontabs every 10 seconds to check if the phone is connected
- script does:
iwinfo wlan0 assoclistto check if my phone's MAC is connected
- if my phone is connected, send wake-on-lan packet
- keep a boolean pcHasBeenWokenUp so the script doesn't send WOL packets all the time (because the phone is connected )
- when the phone disappeared for > 10 minutes: set pcHasBeenWokenUp to false
a. Is this the right direction?
b. Should the script be a bash script or rather something like perl?
c. How can I maintain my pcHasBeenWokenUp variable between the starts of my script?
Some hints would be highly appreciated :)