0

I'm executing a python script

 subprocess.call("/home/scripts/secondary.py", shell=True)

from inside my primary.py script situated at the same location.Now, I want to pass multiple arguments to the secondary.py. I have doubts pertaining to two things-

1)How do I pass the arguments and use them in the secondary script?

I've trying to pass them as--

     import subprocess

     subprocess.call("/home/scripts/secondary.py", "arg1", "arg2",shell=True)

But, having difficulties as to how do I use the passed variables.Also, I don't know if it's the correct way or not.

4
  • Please be clearer about the difficulties you are having. You can only pass string text values on the command-line. Are you trying to share variables? Commented Nov 4, 2016 at 7:59
  • Hi, I want to pass arguments like A and B for reference and do some meanignful operations.I'm passing arguments A and B as command line arguments in the primary script and calling the seconadary script from inside primary script. Commented Nov 4, 2016 at 8:10
  • I still don't understand what difficulties you meet for this purpose. Commented Nov 4, 2016 at 8:28
  • Okay,I'll try to be clearer this time. The difficulties I'm facing is 1) I want to know if the below is the correct way to pass the arguments. subprocess.call("/home/scripts/secondary.py", "arg1", "arg2",shell=True) 2)And secondly,once in secondary.py can I directly use the arguments like arg1 and arg2..or do I need to retrieve it from a argv[] list. Commented Nov 4, 2016 at 8:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.