Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Using wildcards with Popen in the Subprocess module (http://www.velocityreviews.com/forums/t484646-re-using-wildcards-with-popen-in-the-subprocess-module.html)

William Hudspeth 03-15-2007 09:46 PM

Re: Using wildcards with Popen in the Subprocess module
 
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


Sion Arrowsmith 03-16-2007 11:56 AM

Re: Using wildcards with Popen in the Subprocess module
 
William Hudspeth <wbhk@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@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


All times are GMT. The time now is 12:35 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.