subprocess.Popen on Windows

Discussion in 'Python' started by Werner F. Bruhin, Oct 20, 2008.

  1. I am trying to use subprocess - it basically works but.

    command = 'ping ' + '-n '+ str(count) + ' -l ' +
    str(size) + ' ' + str(node)
    print command
    p = subprocess.Popen(command, stdin=subprocess.PIPE,
    stdout=subprocess.PIPE)
    pout = p.stdout.read()

    This works for me but I see the Windows command window, is there a way
    to call subprocess without a command window showing?

    I am trying to replace:

    fdout, fdin = popen2.popen4('ping -n '+ str(count)+ ' -l '+ str(size) +'
    '+node)

    Which did not show the command window.

    I did quit a bit of googling bug so far did not find an answer to my
    problem.

    Appreciate any hints on how this can be accomplished.

    Werner
     
    Werner F. Bruhin, Oct 20, 2008
    #1
    1. Advertising

  2. Werner F. Bruhin

    Eric Carlson Guest

    Werner F. Bruhin wrote:
    > I am trying to use subprocess - it basically works but.
    >
    > command = 'ping ' + '-n '+ str(count) + ' -l ' +
    > str(size) + ' ' + str(node)
    > print command
    > p = subprocess.Popen(command, stdin=subprocess.PIPE,
    > stdout=subprocess.PIPE)
    > pout = p.stdout.read()
    >
    > This works for me but I see the Windows command window, is there a way
    > to call subprocess without a command window showing?
    >
    > I am trying to replace:
    >
    > fdout, fdin = popen2.popen4('ping -n '+ str(count)+ ' -l '+ str(size) +'
    > '+node)
    >
    > Which did not show the command window.
    >
    > I did quit a bit of googling bug so far did not find an answer to my
    > problem.
    >
    > Appreciate any hints on how this can be accomplished.
    >
    > Werner


    Try:

    p = subprocess.Popen(command, shell=True, tdin=subprocess.PIPE,
    stdout=subprocess.PIPE)

    was working on xp and osx
     
    Eric Carlson, Oct 20, 2008
    #2
    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. madpython

    subprocess.Popen on Windows

    madpython, Jun 23, 2006, in forum: Python
    Replies:
    3
    Views:
    8,236
    Uri Nix
    Jun 25, 2006
  2. Méta-MCI

    Windows, subprocess.Popen & encodage

    Méta-MCI, May 8, 2007, in forum: Python
    Replies:
    2
    Views:
    397
  3. Tim Golden
    Replies:
    0
    Views:
    459
    Tim Golden
    Oct 7, 2007
  4. Replies:
    8
    Views:
    749
  5. Mark Shewfelt
    Replies:
    1
    Views:
    619
    yomgui
    Nov 6, 2008
Loading...

Share This Page