subprocess.Popen fails, but os.system works

Discussion in 'Python' started by bahoo, Apr 25, 2007.

  1. bahoo

    bahoo Guest

    Hi,

    I am using Windows + Python 2.5.

    This line of code fails (see error message at the end),

    last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
    images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]

    but using "os.system" works:
    os.system('D:/release/win.exe 0.5 1000 100 D:/images/img.ppm out.ppm')

    ----------
    C:/Python25/pythonw.exe -u "D:/run.pyw"
    Traceback (most recent call last):
    File "D:/run.pyw", line 59, in <module>
    process_dir(mydir)
    File "D:/run.pyw", line 52, in process_dir
    segmentation (dir,f)
    File "D:/run.pyw", line 35, in segmentation
    last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
    images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]
    File "C:\Python25\lib\subprocess.py", line 593, in __init__
    errread, errwrite)
    File "C:\Python25\lib\subprocess.py", line 793, in _execute_child
    startupinfo)
    WindowsError: [Error 22] The filename, directory name, or volume label
    syntax is incorrect
    -----------

    Can anyone tell me why?
    Thanks
    bahoo
     
    bahoo, Apr 25, 2007
    #1
    1. Advertisements

  2. In <>, bahoo wrote:

    > This line of code fails (see error message at the end),
    >
    > last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
    > images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]
    >
    > but using "os.system" works:
    > os.system('D:/release/win.exe 0.5 1000 100 D:/images/img.ppm out.ppm')
    >
    > ----------
    > C:/Python25/pythonw.exe -u "D:/run.pyw"
    > Traceback (most recent call last):
    > File "D:/run.pyw", line 59, in <module>
    > process_dir(mydir)
    > File "D:/run.pyw", line 52, in process_dir
    > segmentation (dir,f)
    > File "D:/run.pyw", line 35, in segmentation
    > last_line = subprocess.Popen(["D:/release/win.exe 0.5 1000 100 D:/
    > images/img.ppm out.ppm"], stdout=subprocess.PIPE).communicate()[0]
    > File "C:\Python25\lib\subprocess.py", line 593, in __init__
    > errread, errwrite)
    > File "C:\Python25\lib\subprocess.py", line 793, in _execute_child
    > startupinfo)
    > WindowsError: [Error 22] The filename, directory name, or volume label
    > syntax is incorrect
    > -----------
    >
    > Can anyone tell me why?


    You are trying to execute a program named::

    D:/release/win.exe 0.5 1000 100 D:/images/img.ppm out.ppm

    Such a program does not exist on your computer. ;-)

    Give `subprocess.Popen()` a list with the program name and the individual
    arguments as elements instead.

    Ciao,
    Marc 'BlackJack' Rintsch
     
    Marc 'BlackJack' Rintsch, Apr 25, 2007
    #2
    1. Advertisements

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. Mr Marsh
    Replies:
    2
    Views:
    394
    Peter Marsh
    Nov 4, 2003
  2. M. Craig
    Replies:
    2
    Views:
    6,321
    M. Craig
    Nov 19, 2003
  3. Earl Eiland
    Replies:
    3
    Views:
    707
    Peter Hansen
    May 16, 2005
  4. Replies:
    2
    Views:
    2,012
    Nick Craig-Wood
    Aug 24, 2006
  5. newton10471
    Replies:
    3
    Views:
    684
    newton10471
    Mar 25, 2010
  6. Chris Curvey
    Replies:
    2
    Views:
    843
    Tim Golden
    Oct 13, 2010
  7. Replies:
    4
    Views:
    270
  8. Niklas Berliner
    Replies:
    0
    Views:
    277
    Niklas Berliner
    Jan 10, 2013
Loading...