Using os.system() and string concatenation

Wayne Witzel III wwitzel3 at gmail.com
Tue Oct 12 15:21:00 EDT 2004


On Tue, 12 Oct 2004 21:02:53 +0200, Fredrik Lundh
<fredrik at pythonware.com> wrote:
> 
> 
> 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".
>

No, I was properly inserting the spaces. When I changed it to a print
statement and executed the resulting output, it worked just fine.
Change it back to os.system() call and it would not work unless I
placed the entire command in the cmd variable.

Seemed very odd to me. Could have been an error I didn't notice and
fixed them I the string to all being stored in the variable, but then
why would the output of the print statement work when I copy and
pasted it?



More information about the Python-list mailing list