Re: How to check if Pexpect child already exist?

Discussion in 'Python' started by Dave Angel, Dec 5, 2012.

  1. Dave Angel

    Dave Angel Guest

    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@192.168.1.105')
    > 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
    what?

    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.

    --

    DaveA
     
    Dave Angel, Dec 5, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Rodriguez
    Replies:
    23
    Views:
    1,141
    David Schwartz
    Dec 9, 2003
  2. Noah Roberts

    Does this already exist?

    Noah Roberts, Nov 20, 2006, in forum: C++
    Replies:
    2
    Views:
    292
    Noah Roberts
    Nov 20, 2006
  3. Adrian Casey
    Replies:
    1
    Views:
    476
    Gabriel Genellina
    May 25, 2011
  4. Saqib Ali
    Replies:
    1
    Views:
    363
    Roy Smith
    Dec 26, 2011
  5. Z W
    Replies:
    0
    Views:
    179
Loading...

Share This Page