Using os.system() and string concatenation
steven.bethard at gmail.com
Tue Oct 12 20:57:06 CEST 2004
Wayne Witzel III <wwitzel3 <at> gmail.com> writes:
> cmd = "/usr/sbin/useradd"
> os.system(cmd + list1 + list1 + list2 + list3)
Are you inserting spaces appropriately? The code above makes one long command
that looks like "usr/sbin/useraddoutput1output2output3output4". Is this what
you meant to do?
If not, you could try something like:
os.system(' '.join([cmd, list1, list1, list2, list3]))
which should put spaces between the command and each of the entries...
If this is not what you're trying to do, could you give us a little more
information on what the listi[j] things contain? An example of what
print cmd + list1 + list1 + list2 + list3
outputs would also be helpful.
More information about the Python-list