Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Subprocess.Popen - passing args help

Reply
Thread Tools

Subprocess.Popen - passing args help

 
 
Ernesto
Guest
Posts: n/a
 
      11-02-2005
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,

 
Reply With Quote
 
 
 
 
Ernesto
Guest
Posts: n/a
 
      11-02-2005
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?

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      11-02-2005
"Ernesto" wrote:

> 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&00 00'

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

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

</F>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
forwarding Args&&... vs forwarding Args... Andrew Tomazos C++ 5 01-05-2012 11:15 PM
C++0x -- fun(Args&...) and fun(Args const&...) er C++ 2 12-20-2010 07:52 PM
Is there a class or method to construct url args or extract url args? Ken Varn ASP .Net 2 06-22-2005 12:26 PM
args v. *args passed to: os.path.join() Pierre Fortin Python 2 09-18-2004 06:59 PM
When passing functions as args,how to pass extra args for passed function? python@sarcastic-horse.com Python 3 09-17-2003 12:25 AM



Advertisments