send command to parent shell

Giampaolo Rodolà g.rodola at gmail.com
Thu Oct 14 10:00:49 EDT 2010


On Wed, 13 Oct 2010 06:30:15 -0700, Martin Landa wrote:
> is there a way how to send command from python script to the shell
> (known id) from which the python script has been called?

By using psutil (http://code.google.com/p/psutil/):

giampaolo at ubuntu:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil, os
>>> me = psutil.Process(os.getpid())
>>> me.name
'python'
>>> parent = me.parent
>>> parent.name
'bash'
>>> parent.kill()


Regards,

--- Giampaolo
http://code.google.com/p/pyftpdlib/
http://code.google.com/p/psutil/



More information about the Python-list mailing list