I want to run a python script from another python script. I want to pass variables like I would using the command line.
For example, I would run my first script that would iterate through a list of values (0,1,2,3) and pass those to the 2nd script "script2.py 0" then "script2.py 1", etc.
I found SO 1186789 which is a similar question but ars's answer calls a function, where as I want to run the whole script not just a function, and balpha's answer calls the script but with no args. I altered this to something like the below as a test:
execfile("script2.py 1")
But is is not accept vars properly. When I print out the 'sys.argv' ins script2.py it is the original command call to first script "['C:\script1.py'].
I don't really want to change the original script (i.e. script2.py in my example) since I don't own it.
I figure there must be a way to do this, I am just confused how you do it.
Thanks!