Can we pass some arguments to system("cmdline")?
Qiangning Hong
hongqn at gmail.com
Mon Jun 20 02:23:07 EDT 2005
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")
>
> would cause python to execute "ls dir" where "dir" might not exist at
> all! Is there a way to reproduce the same thing in Python?
>
> Thanks for any insights.
>
> cheers,
> Didier.
You should use something like this:
dir = "/home/cypher"
system("ls %s" % dir)
--
Qiangning Hong
_______________________________________________
/ lp1 on fire \
| |
\ -- One of the more obfuscated kernel messages /
-----------------------------------------------
\
\
\
___ _____ ___
/ \ / /| / \
| | / / | | |
| | /____/ | | |
| | | | | | |
| | | {} | / | |
| | |____|/ | |
| | |==| | |
| \___________/ |
| |
| |
More information about the Python-list
mailing list