How to ping and shutdown a remote computer?

Christophe chris.cavalaria at free.fr
Wed Feb 14 11:09:53 EST 2007


joja15 at gmail.com a écrit :
> I am working on a Python script to perform as a remote computer
> manager. So far I have a WOL function working and I would like to add
> the ability to show if a machine is on or off (I figured I would do so
> by pinging the machine and seeing if I get a response). I would also
> like to add the ability to remotely shutdown a computer from the
> python script. Does anyone have a code snippet for pinging an IP, a
> code snippet for shutting down a remote Windows XP machine, and a code
> snippet for sending a HTTP request?
> 
> Here is my current setup:
> 
> - PC  running python script
> - FreeNAS (media server running on FreeBSD. Can be shutdown from web
> interface so I planned on just sending that same web button click from
> the python script to shutdown the FreeNAS server)
> - Windows XP machine with folder share (What packet is sent over the
> network to remotely shutdown a Windows XP machine?)

import os
os.system("shutdown -s -f")
Try other switches if you want. Requires Windows XP at the minimum.



More information about the Python-list mailing list