1

I've wrote a python script to check whether a condition has been fulfilled(in this case, the condition is a tweet).

Now, I want the computer to shutdown if the condition has been fulfilled. How do I use the result Python provides to invoke a shutdown command in Ubuntu?

3 Answers 3

2
os.system('shutdown -h now')

?

Sign up to request clarification or add additional context in comments.

1 Comment

@infoquad: you should accept this answer if you feel it's correct (click the tick icon below the answer's rating). this gives you and the author of the answer reputation and will help future visitors to quickly find the best answer.
0
import os

if condition:
  os.system("shutdown -h now")

Just make sure the user running the script has privileges to call shutdown.

Comments

0

You can write a simple bash script that checks the result of your python program, and uses the terminal command "shutdown -h now".

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.