how do I run fetchmail only if the laptop is connected?(ubuntu)
Peter Smerdon
psmerdon-J4oS66wZXds at public.gmane.org
Fri Feb 29 20:55:04 UTC 2008
Hello, at home on my desktop I have in my crontab:
# m h dom mon dow command
cron */10 * * * * /usr/bin/fetchmail -s >> /home/peter/cronlog 2>&1
Which pulls in my email every ten minutes, but when I am on the road, I
would like to only run fetchmail (from cron) if I have a network
connection.
In Debian, the following would work:
,----[ fetchmail_if_connected.sh ]
| #!/bin/zsh
|
| DEVICES='wlan0:eth0'
| FETCHMAIL='/usr/bin/fetchmail'
| OPTIONS='-s'
|
| devices=`echo $DEVICES | sed 's/:/\\\|/g'`
| ifstate=`grep '\('$devices'\)' /etc/network/ifstate`
| if [[ $ifstate != "" ]] ; then
| $FETCHMAIL $OPTIONS
| fi
`----
However on my ubuntu laptop there is no such file /etc/network/ifstate,
I am not sure if it is because I am using NetworkManager or because it
simply does not exist in ubuntu. So, I just need to know how to tell if
either wlan0 or eth0 is up. Any advice?
--
Peter.
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list