(Q) Running a program if and only if connected
Michael Renzmann
mrenzmann at dylanic.de
Sun Sep 22 19:57:15 EST 2002
Hi.
Timothy Murphy wrote:
> I want to run a program on my laptop when I switch on
> if and only if it is connected to my desktop.
> What is the best way to do this?
If your desktop has a static IP address, try the following:
ping -c <desktop-ip> > /dev/null && echo "i'm connected to the desktop"
|| echo "desktop is not there"
Only drawback: if the ip is not reachable the above command delays for
about 5 seconds.
If pinging the ip is not "secure" enough (i.e. if you are sometimes
connected to networks where another computer than your desktop has the
same ip as your desktop) you could try to work with an arpping on the
mac address of your desktop's network interface. arpping is part of the
iproute2-package.
Bye, Mike
More information about the wireless
mailing list