I want 1.py to call 2.py.

1.py takes an Ip address as a command line argument. I am trying a 'subprocess.call()' in 1.py to call 2.py.

I have defined addr= sys.argv[1] before the main() of 1.py. I want the same address to be accessed in 2.py.

In short, 1.py should call 2.py, which in turn calls 3.py and so on, just by one command

python 1.py ipaddress and this address has to be passed on to all other scripts. how can this be done?

To add on...

i have used

subprocess.call(,shell=True) within the main of 1.py

also have defined addr=sys.argv[1] before the main() of 2.py

I know I am wrong somewhere in taking that system argument, but not able to nail it.

it is giving me the error:

self.transportAddr = (
socket.gaierror:(11001,'getaddrinfo failed')

Thanks for the patient reading!

You pass the string addr to 2.py. Try printing out the command before you make the call.

Correctly:
subprocess.call( ,shell=True)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.