unexpected os.system behavior on windows NT 
Author Message
 unexpected os.system behavior on windows NT

os.system seems to malfunction when the command name and another
argument are both quoted on the commandline.  All these commands
run "as expected" when executed directly in a command window.

Quote:
>>> import os
>>> os.system(r'"cmd.exe" /c echo "hi bob"')

The system cannot find the path specified.
1
Quote:
>>> os.system(r'"cmd.exe" /c echo hi bob')

hi bob
0
Quote:
>>> os.system(r'cmd.exe /c echo "hi bob"')

"hi bob"
0

Quote:
>>> os.system(r'cmd.exe /c echo "hi bob"')

"hi bob"
0
Quote:
>>> os.system(r'cmd.exe /c "echo" "hi bob"')

The name specified is not recognized as an
internal or external command, operable program or batch file.
0
Quote:
>>> os.system(r'cmd.exe /c "echo" hi bob')

hi bob
0

The same holds for os.popen, popen2.popen*, and win32pipe.popen*
though I haven't tried all the variations there.

I've kludged around this by using the 8.3 pathname for the executable,
so that I am guaranteed to not need to quote it ..

Jeff



Mon, 25 Oct 2004 02:37:42 GMT  
 unexpected os.system behavior on windows NT

Quote:
> os.system seems to malfunction when the command name and another
> argument are both quoted on the commandline.  All these commands
> run "as expected" when executed directly in a command window.

I've posted this before... There are strange rules of cmd.exe regarding
quotes, but 'cmd /?' on Win2k finally documents them.

Thomas
-----
If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:

    1.  If all of the following conditions are met, then quote characters
        on the command line are preserved:

        - no /S switch
        - exactly two quote characters
        - no special characters between the two quote characters,

        - there are one or more whitespace characters between the
          the two quote characters
        - the string between the two quote characters is the name
          of an executable file.

    2.  Otherwise, old behavior is to see if the first character is
        a quote character and if so, strip the leading character and
        remove the last quote character on the command line, preserving
        any text after the last quote character.



Mon, 25 Oct 2004 03:34:41 GMT  
 unexpected os.system behavior on windows NT
For questions regarding command line stuff on Windows, check out
www.technet.com. I get really irritated because cmd.exe has very little
documentation, but I've been able to find a lot at this site. Good luck!

Gabe

Quote:
-----Original Message-----

Sent: Wednesday, May 08, 2002 5:39 PM
To: Thomas Heller


Subject: Re: unexpected os.system behavior on windows NT


> > os.system seems to malfunction when the command name and another
> > argument are both quoted on the commandline.  All these commands
> > run "as expected" when executed directly in a command window.

> I've posted this before... There are strange rules of cmd.exe
regarding
> quotes, but 'cmd /?' on Win2k finally documents them.

Thanks .. this is something that's always frustrated/puzzled me.  I
think
there are two pieces missing still, which must be documented somewhere
    -- how does an exec* argument list get turned into a command line?
    -- how does the target program parse that back into an argc/argv
list?

I started to get the results I expected as soon as I used an 8.3 name
for
the executable and quoted any argument with whitespace (not handling any
more esoteric characters properly), but I hear that some versions of
windows disable 8.3 compatability names.  I don't know how I'd refer to
"C:\Program Files\Software Company\Product Name\Nose Monkeys.exe"
without them, though..

I wish somebody I worked with Really Understood (TM) NT.

Jeff

--
http://mail.python.org/mailman/listinfo/python-list



Mon, 25 Oct 2004 08:45:15 GMT  
 unexpected os.system behavior on windows NT

Quote:

> > os.system seems to malfunction when the command name and another
> > argument are both quoted on the commandline.  All these commands
> > run "as expected" when executed directly in a command window.

> I've posted this before... There are strange rules of cmd.exe regarding
> quotes, but 'cmd /?' on Win2k finally documents them.

Thanks .. this is something that's always frustrated/puzzled me.  I think
there are two pieces missing still, which must be documented somewhere
    -- how does an exec* argument list get turned into a command line?
    -- how does the target program parse that back into an argc/argv list?

I started to get the results I expected as soon as I used an 8.3 name for
the executable and quoted any argument with whitespace (not handling any
more esoteric characters properly), but I hear that some versions of
windows disable 8.3 compatability names.  I don't know how I'd refer to
"C:\Program Files\Software Company\Product Name\Nose Monkeys.exe"
without them, though..

I wish somebody I worked with Really Understood (TM) NT.

Jeff



Mon, 25 Oct 2004 08:39:26 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using os.system and os.popen from pythonwin under Windows NT

2. os.system limitations on Windows NT

3. Behavior of os.system() with redirection

4. New Behavior of os.system() in Python 2.0?

5. Windows NT wierd behavior

6. Unexpected right-click behavior in a tree view

7. Unexpected behavior of }

8. CW4 - Bug or just 'unexpected behavior'?? :-)

9. Unexpected behavior of a custom control

10. Unexpected behavior of rxstack.exe? (Regina 3.0, Win32)

11. Unexpected behavior with class and instance variables...

12. Unexpected behavior in PythonWin Debugger

 

 
Powered by phpBB® Forum Software