-1

I have done some simple python programing, but I'm no expert, what I need to do is to comunicate a Raspberry Pi with 12 windows PC's, all of the PC's are connected to UPS do to frequent power shutdowns that I have in my country, the Pi will act as a "server" and it will be monitoring the power source and in the case of a shutdown it will send a command to execute a script on each PC so that they can perform a correct shutdown sequence.

I know how to work with the Pi's GPIO on python, but I have no clue how to communicate then over the LAN.

Any help will be appreciated.

Alfonso
  • 29
  • 1
  • 1
  • 2

1 Answers1

0

I think the easiest way to achieve this is by forking off a process using the subprocess module, and calling the command:

net rpc shutdown -f -t 0 -C 'message' -U userName%password -I xxx.yyy.zzz.ttt

source: Shutdown Windows machine from linux terminal

As far as I can tell, there are no python modules that offer a nice implementation of the 'net rpc' tools, so calling them using subprocess is the easiest way. To handle the feedback from the command, I suggest you pipe stdout and stderr back to python and then capture and raising exceptions by scraping the output for keywords.

By no means is this the most Pythonic way, I would be interested to see if anyone else has a more Pythonic way of doing it!

Stuart Buckingham
  • 1,574
  • 16
  • 25