Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

popen[2-4] does not work with parameters inside quotes

1 view
Skip to first unread message

Anders Dalvander

unread,
Oct 30, 2003, 3:07:40 PM10/30/03
to
os.popen[2-4] does not work with parameters inside quotes, nor do
os.popen. At least on Windows.

import os
cmd = '"c:\\command.exe" "parameter inside quotes"'
os.popen4(cmd)

Results in the following error message:

'c:\\command.exe" "parameter inside quotes' is not recognized as an
internal or external command,
operable program or batch file.

// Dalle

Emile van Sebille

unread,
Oct 30, 2003, 3:50:22 PM10/30/03
to
"Anders Dalvander"

> os.popen[2-4] does not work with parameters inside quotes, nor do
> os.popen. At least on Windows.
>
> import os
> cmd = '"c:\\command.exe" "parameter inside quotes"'
> os.popen4(cmd)
>
> Results in the following error message:
>

Hmm... not for me... I get:

>>> import os
>>> cmd = '"c:\\command.exe" "parameter inside quotes"'
>>> os.popen4(cmd)

(<open file '"c:\command.exe" "parameter inside quotes"', mode 'w' at
0x008E6620>, <open file '"c:\command.exe" "parameter insid
e quotes"', mode 'r' at 0x008EC060>)


Emile van Sebille
em...@fenx.com


Derrick 'dman' Hudson

unread,
Oct 30, 2003, 5:30:01 PM10/30/03
to
Anders Dalvander <goo...@dalvander.com> wrote:

> cmd = '"c:\\command.exe" "parameter inside quotes"'
> os.popen4(cmd)

> 'c:\\command.exe" "parameter inside quotes' is not recognized as an


> internal or external command, operable program or batch file.

Not surprising. Pick command.COM or cmd.exe.

-D

--
If your life is a hard drive,
Christ can be your backup.

www: http://dman13.dyndns.org/~dman/ jabber: dm...@dman13.dyndns.org

Anders Dalvander

unread,
Oct 31, 2003, 8:27:01 AM10/31/03
to
Derrick 'dman' Hudson <dm...@dman13.dyndns.org> wrote in message news:<flf871-...@dman13.dyndns.org>...

> Not surprising. Pick command.COM or cmd.exe.

*siq* I should have written anycommand.exe instead of command.exe...

Anders Dalvander

unread,
Oct 31, 2003, 8:29:28 AM10/31/03
to
"Emile van Sebille" <em...@fenx.com> wrote in message news:<bnrte4$14vkmn$1...@ID-11957.news.uni-berlin.de>...

> Hmm... not for me... I get:
>
> >>> import os
> >>> cmd = '"c:\\command.exe" "parameter inside quotes"'
> >>> os.popen4(cmd)
> (<open file '"c:\command.exe" "parameter inside quotes"', mode 'w' at
> 0x008E6620>, <open file '"c:\command.exe" "parameter insid
> e quotes"', mode 'r' at 0x008EC060>)
>

Did you try with having the exe-file in another directory with spaces:
"c:\path with spaces\command.exe"?

What Windows version are you running?

// Dalle

Jimmy Retzlaff

unread,
Oct 31, 2003, 10:36:08 AM10/31/03
to pytho...@python.org
Anders Dalvander wrote:
> os.popen[2-4] does not work with parameters inside quotes, nor do
> os.popen. At least on Windows.
>
> import os
> cmd = '"c:\\command.exe" "parameter inside quotes"'
> os.popen4(cmd)
>
> Results in the following error message:
>
> 'c:\\command.exe" "parameter inside quotes' is not recognized as an
> internal or external command,
> operable program or batch file.

Take a look at this (especially Tim Peters' very thorough explanation in
the Followups section):

http://sf.net/tracker/?func=detail&aid=512433&group_id=5470&atid=105470

Perhaps this is what you are seeing? One workaround (that isn't
beautiful) might be to create a temporary batch file with your command
line and execute that batch file.

Jimmy


Emile van Sebille

unread,
Oct 31, 2003, 11:29:21 AM10/31/03
to

"Anders Dalvander" <goo...@dalvander.com> wrote in message
news:d04c84a9.03103...@posting.google.com...

This wraps, but here's the result:

Python 2.4a0 (#46, Oct 25 2003, 09:39:59) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> cmd = '"C:\\Program Files\\Microsoft Visual
Studio\\Common\\Tools\\dfview.ex


e" "parameter inside quotes"'
>>> os.popen4(cmd)

(<open file '"C:\Program Files\Microsoft Visual
Studio\Common\Tools\dfview.exe"
"parameter inside quotes"', mode 'w' at 0x008E4EE0>, <open file '"C:\Program
Fil
es\Microsoft Visual Studio\Common\Tools\dfview.exe" "parameter inside
quotes"',
mode 'r' at 0x008EC660>)
>>>

>
> What Windows version are you running?
>

This was on winxppro.

Emile


0 new messages