Using wildcards with Popen in the Subprocess module
Sion Arrowsmith
siona at chiark.greenend.org.uk
Fri Mar 16 07:56:05 EDT 2007
William Hudspeth <wbhk at unm.edu> 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 -- siona at chiark.greenend.org.uk -- 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
More information about the Python-list
mailing list