execute bash builtins in python

Chris Colbert sccolbert at gmail.com
Wed Mar 17 19:14:14 CET 2010

On Wed, Mar 17, 2010 at 11:44 AM, Nobody <nobody at nowhere.com> wrote:

> On Fri, 12 Mar 2010 08:15:49 -0500, Steve Holden wrote:
> > For shell=True I believe you should provide the command as a single
> > string, not a list of arguments.
> Using shell=True with an argument list is valid.
> On Unix, it's seldom what you want: it will invoke /bin/sh to execute the
> first argument with $1, $2, ... set from the remaining arguments.
> On Windows, a list is converted to a string in the same manner regardless
> of the value of the "shell" argument. Specifying shell=True causes the
> command string to be executed via "cmd /c ...". This allows the "program"
> to be a script, whereas shell=False requires the program to be a binary
> executable.
> --
> http://mail.python.org/mailman/listinfo/python-list

if you can work interactively, save yourself the headache and just use

brucewayne at broo:~$ ipython
Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: alias
Total number of aliases: 15
[('cat', 'cat'),
 ('clear', 'clear'),
 ('less', 'less'),
 ('mkdir', 'mkdir'),
 ('rmdir', 'rmdir'),
 ('cp', 'cp -i'),
 ('lc', 'ls -F -o --color'),
 ('ldir', 'ls -F -o --color %l | grep /$'),
 ('lf', 'ls -F -o --color %l | grep ^-'),
 ('lk', 'ls -F -o --color %l | grep ^l'),
 ('ll', 'ls -lF'),
 ('ls', 'ls -F'),
 ('lx', 'ls -F -o --color %l | grep ^-..x'),
 ('mv', 'mv -i'),
 ('rm', 'rm -i')]

In [2]:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100317/b42baeab/attachment.html>

More information about the Python-list mailing list