<br><div class="gmail_quote">On Tue, Oct 26, 2010 at 3:31 AM, Sean Carolan <span dir="ltr"><<a href="mailto:scarolan@gmail.com">scarolan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I'm rewriting a bunch of my bash scripts to get some python practice.<br>
There are some instances where python doesn't have the built-in text<br>
processing that I need, so I'm using subprocess.call. How can I pass<br>
a python variable to these subprocesses? For example:<br>
<br>
mydir = "/usr/local/bin"<br>
subprocess.call("ls -l /usr/local/bin", shell=True)<br>
<br></blockquote><div>subprocess.call("ls -l "+mydir,shell=True) <br>will do the job. In python, we can simply concatenate the strings like that.<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
How do I replace /usr/local/bin in the subprocess call with the mydir variable?<br>
_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Abhijeet Rastogi (shadyabhi)<br><a href="http://www.google.com/profiles/abhijeet.1989" target="_blank">http://www.google.com/profiles/abhijeet.1989</a><br>