[Tutor] passing variables to the system command

Tzu-Ming Chern T.Chern at unibas.ch
Thu Aug 5 22:38:54 CEST 2004


Hi Python tutors,

I'm having problems finding a way to pass variables when using the systems
command in python. For example, in a simple python script, I would like to
run another python script using the systems command. This python script
takes the variables (argument1 and 2) as commandline arguments, which are
filenames infact. The python scripts and all the filenames are in the same
directory. See the following for example:

import os

argument1 = filename1
argument2 = filename2

os.system("some_other_python_script.py argument1 argument2")

or

os.system("chmod u+x argument1")
---------------------------------------

When I try to run this, I get the error that the variables passed (which
are filenames) cannot be opened. What is the correct syntax to run another
script that takes in commandline arguments in a python script using the
unix systems command?

cheers,
Tzu-Ming



More information about the Tutor mailing list