Subprocess.Popen - passing args help

Discussion in 'Python' started by Ernesto, Nov 2, 2005.

  1. Ernesto

    Ernesto Guest

    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,
     
    Ernesto, Nov 2, 2005
    #1
    1. Advertising

  2. Ernesto

    Ernesto Guest

    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?
     
    Ernesto, Nov 2, 2005
    #2
    1. Advertising

  3. "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&0000'

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

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

    </F>
     
    Fredrik Lundh, Nov 2, 2005
    #3
    1. Advertising

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. Ken Varn
    Replies:
    2
    Views:
    658
    Ken Varn
    Jun 22, 2005
  2. Replies:
    3
    Views:
    540
    David Eppstein
    Sep 17, 2003
  3. Pierre Fortin

    args v. *args passed to: os.path.join()

    Pierre Fortin, Sep 18, 2004, in forum: Python
    Replies:
    2
    Views:
    755
    Pierre Fortin
    Sep 18, 2004
  4. Brandon Harris

    Passing File Objects into Subprocess.Popen

    Brandon Harris, Nov 4, 2010, in forum: Python
    Replies:
    0
    Views:
    408
    Brandon Harris
    Nov 4, 2010
  5. er
    Replies:
    2
    Views:
    544
Loading...

Share This Page