Subprocess.Popen - passing args help

E

Ernesto

I'm trying to use Popen to do some command line work Windows XP style.
I have devcon.exe which I would use on a Windows command line like so:

devcon disable "@USB\VID_05E3&PID_0605\5&2CE74B9E&1&6"

Using subprocess.Popen, I have something like this:

subprocess.Popen([r"devcon.exe","disable",'"USB\VID_05E3&PID_0605\5&2CE74B9E&1&6"']).wait();

For some reason, the parameters are not getting passed to devcon
correctly. Devcon executes, but doesn't behave the same way it does if
I type in the command above at a Win Prompt. Any clues as to how to
pass these parameters? Thanks,
 
E

Ernesto

A nice person from another thread helped me...

a = 'disable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000'
print a
disable "@USB\VID_0403&PID_6010&MI_00&15E4F68&1&0000

\7 is the ASCII bell so your args may be different from what you think.


I thought the quote method I have fixes this problem, but I guess I was
wrong. Anyone have suggestions on how I can get that parameter in
there without the '\7' part getting lost?
 
F

Fredrik Lundh

Ernesto said:
A nice person from another thread helped me...

a = 'disable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000'
print a
disable "@USB\VID_0403&PID_6010&MI_00&15E4F68&1&0000

\7 is the ASCII bell so your args may be different from what you think.


I thought the quote method I have fixes this problem, but I guess I was
wrong. Anyone have suggestions on how I can get that parameter in
there without the '\7' part getting lost?

try

a = r'disable "@USB\VID_0403&PID_6010&MI_00\7&15E4F68&1&0000'

or

a = 'disable "@USB\\VID_0403&PID_6010&MI_00\\7&15E4F68&1&0000'

also see section 3.1.2 in the Python Tutorial, and this page:

http://docs.python.org/ref/strings.html

</F>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top