RP-beginner here,
Background
I'm using a shell script called Sakis3g to connect to internet and it works very well (It uses wvdial in the background and sets up a ppp-connection)
I want Sakis3g to run automatically and connect to a USB-modem (D-Link DWM-222) when the raspberry is booted to enable me to SSH into it from another computer. I know this can be done in multiply ways, such as placing the command in rc.local or init.d.
The problem
The thing is that the network I'm connecting to is not the public internet but hosted locally at a site. This network is not always available and the "sudo sakis3g connect" would fail.
What I want
I want to know that the modem has found the network before executing the "sudo sakis3g connect"
Question
What is the best way to go about this? Is there any way to trigger the command upon network identification? Or should I just keep running the command until it succeeds?