On 25-Oct-10 15:19, Abhijeet Rastogi wrote:
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?
It's often preferable (for reasons ranging from security to coding style) to use the array call style for the subprocess methods, so instead of a string which must then be interpreted by the shell (and allowing for unintended interpretation of shell characters like quotes and wildcards), you instead pass a list of values for the new process, so the shell is never even involved:
subprocess.call(['ls', '-l', mydir]) _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
