send command to parent shell

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


Sorry I realize now that you wrote "how to send a command to the
shell" and not "how to kill the shell".
In this case I don't know exactly what you mean.



Regards,

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

2010/10/14 Giampaolo Rodolà <g.rodola at gmail.com>:
> 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