Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Using wildcards with Popen in the Subprocess module

Reply
Thread Tools

Re: Using wildcards with Popen in the Subprocess module

 
 
William Hudspeth
Guest
Posts: n/a
 
      03-15-2007
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

 
Reply With Quote
 
 
 
 
Sion Arrowsmith
Guest
Posts: n/a
 
      03-16-2007
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
 
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
os.popen and the subprocess module Andrew Python 3 11-30-2012 06:01 PM
Re: os.popen and the subprocess module Mark Lawrence Python 0 11-27-2012 06:29 PM
subprocess.Popen and thread module Danny Wong (dannwong) Python 1 08-10-2011 10:09 AM
Using wildcards with Popen in the Subprocess module William Hudspeth Python 2 03-15-2007 07:47 PM
[Subprocess/Windows] subprocess module under Windows 98 Andreas Jung Python 2 11-02-2005 05:41 PM



Advertisments