Hello. I have come across many scripts for rebooting remote computers using python, but what about the computer the script is running on? If possible, I would also like my script to run in the background so the little cmd box is not visible. Thanks in advance for your help.
dantheman3141
20
Newbie Poster
Recommended Answers
Jump to PostI think you can have it pass the command to the computer via the
os
module. Like for Debian-based GNU/Linux distros you could write:import os os.system("halt")
The only problem I can think of is that this would require super-user privileges to execute the shut down.
…
Jump to PostThis mail might help:
http://mail.python.org/pipermail/python-list/2002-August/161778.htmlIt looks like there are some good example's of it being used in the code, and about adjusting privileges.
EDIT:
It looks like the last argument you'd want to be 1 or True because that's the reboot option...
All 6 Replies
shadwickman
159
Posting Pro in Training
dantheman3141
20
Newbie Poster
shadwickman
159
Posting Pro in Training
dantheman3141
20
Newbie Poster
shadwickman
159
Posting Pro in Training
dantheman3141
20
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.