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

Andreas Kostyrka andreas at kostyrka.org
Mon Jun 20 02:24:35 EDT 2005


On Sun, Jun 19, 2005 at 11:12:05PM -0700, Didier C wrote:
> Hi!
>    I was wondering if we can pass some arguments to system("cmdline")?
> 
> E.g in Perl, we can do something like:
> 
> $dir="/home/cypher";
> 
> system("ls $dir");
> 
> which would instruct Perl to do an "ls /home/cypher"
> 
> But in python, doing something like
> 
> dir="/home/cypher"
> system("ls dir")
system("ls %(dir)s" % locals())
system("ls %s" % dir)
system("ls %(name)s" % dict(name=dir)

But you should consider if you really really want to do this.
What happens when " " in dir?
What happens when dir == "; rm -Rf /"

Andreas



More information about the Python-list mailing list