3
rated 0 times
[
3]
[
0]
/ answers: 1 / hits: 599
/ 2 Years ago, fri, january 7, 2022, 7:36:02
It works fine from terminal, but when called from a thread in python, it fails.
history -d $((HISTCMD-1)) && echo 'password' | sudo -S shutdown -h 08:00
from python, here's what I did:
halt = "history -d $((HISTCMD-1)) && echo 'password' | sudo -S shutdown -h 08:00"
thread.start_new_thread(lambda: commands.getoutput(halt),())
I used lambda after trying it for other commands like opening nautilus or gedit, which works fine, but shutdown command isn't!
More From » command-line