Here are two scripts. First one called first_py:
#!/usr/bin/env python
import sys
print sys.argv[0] # prints python_script.py
print sys.argv[1] # prints var1
print "first one"
Here's the second one called sec_py:
#!/usr/bin/env python
import sys
print sys.argv[0] # prints sec_script.py
print sys.argv[1] # prints var1
print "second one"
x=5
myVars = {'x':x}
exec(open('first_py').read(), myVars)
As you can see I'm trying to pass the number '5' as a parameter from the second script to the first script while calling it. It's not working.
How can I fix the second script so it calls first_py and passes the value of 'x' to it so the value 5 is printed out?