Re: How to check if Pexpect child already exist?
On 12/05/2012 02:41 AM, Thomas Elsgaard wrote:
> Hi List
> I am wondering, how can i check if child already exist before i spawn
By definition, before you call the spawn, the child doesn't exist. So
presumably you must mean something else.
> child.isalive() cannot be done on child before it has been spawned.
> import pexpect
> child=pexpect.spawn('ssh firstname.lastname@example.org')
All we have to do is guess what you really mean. Do you mean you want
to know if there are any instances of ssh running? Regardless of how
they got spawned, or from what process? Or are you trying to determine
if the current process (your script) has any children, of any kind? Or
Also, you should probably tell what OS and Python versions you're running.
One approach on Linux might be to capture the output of 'ps aux' and
parse it for whatever match criteria you have.
|All times are GMT. The time now is 04:24 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.