I would like to measure how much a laptop with Windows XP can run on batteries. I have another computer with Xubuntu that I can use to measure if Windows XP computer is on. But how can I connect these two computers and how can I measure if Xubuntu can read data from Windows XP computer? Or should XP send some data to Xubuntu?
I think the easiest solution is using ICMP echo requests (ping). For this, you have to set up the XP box to respond to ICMP messages, as described here.
Now, make sure the Linux and the XP machine are in the same network, and both have an IP address. You can check this on Linux with
and on Windows with
You'll need the XP IP address for the following script:
Save this script in some file, e.g.
pingtimer.sh
and make it executable withchmod +x pingtimer.sh
You can now start it with
from within the same directory.
Let's break this thing down:
time ()
measures the time the command inside the()
took to execute.while [true]; do ...; done
repeats the inner command (...
) infinitely or until interrupted or broken.ping -c 1 "$1" > /dev/null
sends one ping request to the IP address stored in$1
, which is the first program argument, i.e. the target IP. Asping
produces a lot of output, we'll just discard that to/dev/null
... || break
will break the 'infinite' while loop if the command before the||
operator returns a non-zero value. In case of ping, this happens if at least one ICMP packet was not responded to. If this happens, e.g. because the target machine is down, the program will quit, printing the output fromtime
.sleep 60
will cause the process to sleep for 60 seconds, after which another ICMP Echo request is sent. Adjust this value to taste. Note that some firewalls will stop responding if you start flooding it with pings.