Eremis
January 24th, 2010, 11:19 PM
Hi everybody!
I am new to python, and I am trying to figure out how would I make a script that would shutdown my computer after X seconds...
For example when I am downloading something that takes about 2 hours, I could set the script to shutdown PC after 3 hours, and leave home...
So far this is what I have:
#!/usr/bin/python
import os
import time
time.sleep(3600) # after 1 hour shutdown computer
os.system("sudo shutdown now -h -k") # shutdown command
My problem is that ubuntu needs a password to do such tasks, so after 1 hour it will ask me for one (the point being I will not be home to type it...) If I leave out the "sudo" it just gives me an error saying that I dont have permission.. :confused:
Is there a way to become admin, then start the timer, then shut-down (with admin privileges...)? Or is there any other way to acomplish this?
Thanks for the help...
I am new to python, and I am trying to figure out how would I make a script that would shutdown my computer after X seconds...
For example when I am downloading something that takes about 2 hours, I could set the script to shutdown PC after 3 hours, and leave home...
So far this is what I have:
#!/usr/bin/python
import os
import time
time.sleep(3600) # after 1 hour shutdown computer
os.system("sudo shutdown now -h -k") # shutdown command
My problem is that ubuntu needs a password to do such tasks, so after 1 hour it will ask me for one (the point being I will not be home to type it...) If I leave out the "sudo" it just gives me an error saying that I dont have permission.. :confused:
Is there a way to become admin, then start the timer, then shut-down (with admin privileges...)? Or is there any other way to acomplish this?
Thanks for the help...