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.

Mayank Jha
  • 939
  • 3
  • 12
  • 24
  • 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? – cdarke Nov 04 '16 at 07: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. – Mayank Jha Nov 04 '16 at 08:10
  • I still don't understand what difficulties you meet for this purpose. – Kir Chou Nov 04 '16 at 08: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. – Mayank Jha Nov 04 '16 at 08:38

0 Answers0