A
A
ak40u2011-06-29 18:36:24
Python
ak40u, 2011-06-29 18:36:24

How to shutdown ubuntu using python?

Is there a function in python that sends a signal to shutdown ubuntu?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kostik450, 2011-06-29
@kostik450

you can give the superuser attribute directly to shutdown itself
(done once)
sudo chmod +s `which shutdown`
and then, without superuser rights, call shutdown -h now from pearl

S
Sergey, 2011-06-29
@butteff

docs.python.org/library/subprocess.html
www.linux.org.ru/forum/development/6305431
$ python
Python 2.7.1 (r271:86832, Apr 23 2011, 22:48:40)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import Popen, PIPE
>>> Popen("ls -1", shell=True, stdin=PIPE, stdout=PIPE).stdout.read().split()
['1', '111', '222', '333', 'Downloads', 'John', 'Crawford', '(musician)', '-', 'Wikipedia,', 'the', 'free', 'encyclopedia_files', 'John', 'Crawford', '(musician)', '-', 'Wikipedia,', 'the', 'free', 'encyclopedia.html', 'nohup.out', 'Usage', 'xlog']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question