Re: Using wildcards with Popen in the Subprocess module

Discussion in 'Python' started by William Hudspeth, Mar 15, 2007.

  1. Hello Mike,

    Thanks for responding. I need to pass multiple filenames to an
    executable. The filenames are similar to one another, but differ only
    slightly, hence the use of the wildcard. The executable works well from
    the command line if I pass in a wildcard filename, but Popen can't
    expand the wildcard.

    >From command line:

    % command /path_to_files/filename*.doc

    With Popen:
    var1="/path_to_files/filnames*.doc"
    result=Popen(["command",var1]).wait()

    Thanks, I will look into the os.system route.

    Bill
    William Hudspeth, Mar 15, 2007
    #1
    1. Advertising

  2. William Hudspeth <> wrote:
    > [ ... ] I need to pass multiple filenames to an
    >executable. The filenames are similar to one another, but differ only
    >slightly, hence the use of the wildcard. The executable works well from
    >the command line if I pass in a wildcard filename, but Popen can't
    >expand the wildcard.
    >
    >>From command line:

    >% command /path_to_files/filename*.doc
    >
    >With Popen:
    >var1="/path_to_files/filnames*.doc"
    >result=Popen(["command",var1]).wait()


    You want:

    result = Popen(["command", var1], shell=True).wait()

    See the subprocess docs on using Popen instead of "older functions"
    (especially os.system): http://docs.python.org/lib/node534.html .
    You might also want a look at subprocess.call() .

    --
    \S -- -- http://www.chaos.org.uk/~sion/
    ___ | "Frankly I have no feelings towards penguins one way or the other"
    \X/ | -- Arthur C. Clarke
    her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
    Sion Arrowsmith, Mar 16, 2007
    #2
    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. William Hudspeth
    Replies:
    2
    Views:
    295
    Fabio FZero
    Mar 15, 2007
  2. Tim Golden
    Replies:
    0
    Views:
    456
    Tim Golden
    Oct 7, 2007
  3. Danny Wong (dannwong)

    subprocess.Popen and thread module

    Danny Wong (dannwong), Aug 10, 2011, in forum: Python
    Replies:
    1
    Views:
    222
    Thomas Rachel
    Aug 10, 2011
  4. Andrew
    Replies:
    3
    Views:
    150
    emile
    Nov 30, 2012
  5. Mark Lawrence

    Re: os.popen and the subprocess module

    Mark Lawrence, Nov 27, 2012, in forum: Python
    Replies:
    0
    Views:
    140
    Mark Lawrence
    Nov 27, 2012
Loading...

Share This Page