Can we pass some arguments to system("cmdline")?

Didier Casse elprodigio at gmail.com
Mon Jun 20 03:54:08 EDT 2005


Thanks all for the reply. I'll try out those things out. :)

Cheers,
Didier.


Leif K-Brooks a écrit :
> Didier C wrote:
> > E.g in Perl, we can do something like:
> >
> > $dir="/home/cypher";
> >
> > system("ls $dir");
> >
> > Is there a way to reproduce the same thing in Python?
>
> system("ls %s" % dir)
>
> But you should really be using subprocess for security (so that if
> dir=="/home/foo; rm -rf /" nothing bad will happen):
> 
> import subprocess
> subprocess.Popen(['ls', dir])




More information about the Python-list mailing list