Using os.system() and string concatenation
fredrik at pythonware.com
Tue Oct 12 21:02:53 CEST 2004
Wayne Witzel III wrote:
> Currently I process three files and build the output of those files in
> to lists using for statements.
> I think take those lists and provide them to an os.system() call.
> cmd = "/usr/sbin/useradd"
> os.system(cmd + list1 + list1 + list2 + list3)
> This executes without any errors, but doesn't execute the command
> supplied to os.system(). Now if I place them all in cmd first, then
> supply it to os.system() it executes just fine. So there really isn't
> a problem, just wanting to know what would cause such behavior.
the + sign doesn't add a space, so you're probably trying to execute
"/usr/sbin/useraddsomethingsomethingsomethingsomething" instead of
"/usr/sbin/useradd something something something something".
More information about the Python-list