without shell

Steven D'Aprano steve at REMOVETHIScyber.com.au
Fri Jun 10 11:09:41 EDT 2005


On Fri, 10 Jun 2005 14:13:05 +0000, Grant Edwards wrote:

> On 2005-06-10, Steven D'Aprano <steve at REMOVETHIScyber.com.au> wrote:
>> 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.
> 
> It's done by invoking the user's SHELL and passing the string
> "ls" to it.  In the general case, invoking an unknown shell and
> passing it a string is fraught with peril.

Ah... you learn something new every day.

I interpreted the original question as meaning "can Python execute
arbitrary Linux commands without exiting the Python interpretor and
dropping into a shell prompt?".

-- 
Steven.






More information about the Python-list mailing list