I am writing a pyQt client-server application which restarts/shutdowns PCs remotely.
The receivers are listening to the network for incomming messages, and the sender sends a restart/shutdown message to the selected receiver.
The following part of code is running on a receiver:
import os
self.currentOS = calling a function to determine the current OS
if self.currentOS == "Win":
os.system("shutdown -r -f -t 1")
elif self.currentOS == "Lin":
os.system("shutdown -r now")
I have 2 virtual machines acting as receivers, one on Windows and the other on Linux.
When i send a restart message to the Windows receiver, the machine restarts.
When i send a restart message to the Linux receiver, it asks for password
Incoming:EXEC_OP_RESTART
[sudo] password for jwalker:
What do i have to change to overcome this?
Is shutdown -r now
the only way, or can i do this another way (more directly)?
EDIT:
In this question, something called dbus
was used, and it was done without a password, i am searching about dbus, as an alternative.