Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How to check if Pexpect child already exist?

Thread Tools

Re: How to check if Pexpect child already exist?

Dave Angel
Posts: n/a
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 mysurface@')
> child.sendline('test')
> ---

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.



Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
pexpect on windows - child process of another child process - quickquestion Z W Python 0 03-09-2013 10:00 PM
Changing the system clock with pexpect confuses pexpect! Saqib Ali Python 1 12-26-2011 01:51 PM
pexpect: TIMEOUT no longer clears child.before Adrian Casey Python 1 05-25-2011 09:45 AM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM