[Tutor] How to pass a python variable to subprocess.call?
Abhijeet Rastogi
abhijeet.1989 at gmail.com
Tue Oct 26 00:19:53 CEST 2010
On Tue, Oct 26, 2010 at 3:31 AM, Sean Carolan <scarolan at gmail.com> wrote:
> I'm rewriting a bunch of my bash scripts to get some python practice.
> There are some instances where python doesn't have the built-in text
> processing that I need, so I'm using subprocess.call. How can I pass
> a python variable to these subprocesses? For example:
>
> mydir = "/usr/local/bin"
> subprocess.call("ls -l /usr/local/bin", shell=True)
>
> subprocess.call("ls -l "+mydir,shell=True)
will do the job. In python, we can simply concatenate the strings like that.
How do I replace /usr/local/bin in the subprocess call with the mydir
> variable?
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
--
Abhijeet Rastogi (shadyabhi)
http://www.google.com/profiles/abhijeet.1989
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101026/43619e4a/attachment.html>
More information about the Tutor
mailing list