without shell
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Fri Jun 10 10:05:46 EDT 2005
On Sun, 12 Jun 2005 23:16:35 +0530, km wrote:
> hi all,
>
> can any linux command be invoked/ executed without using shell (bash) ?
py> import os
py> status = os.system("ls")
Prints the output of ls and stores the exit code into status.
py> file_list = os.popen("ls").read()
Stores the output of ls into file_list.
Or see the module "commands".
> what abt security concerns ?
Yes, there are serious security concerns. You should be *very* careful
about executing strings generated by users. You probably don't want your
program executing something like os.system("rm -rf /").
--
Steven.
More information about the Python-list
mailing list