Need to call multiple scripts one by one in sequential manner from one script and need to pass command line argument to those multiple script from the common script

0 votes

Need to call multiple scripts  one by one in sequential manner from one script and need to pass command line argument to those multiple script from the common script through them it is called.

Aug 8, 2020 in Python by bhawna
• 120 points

recategorized Aug 10, 2020 by Niroj 4,122 views

1 answer to this question.

0 votes

Hello @bhawna,

You can encapsulate all the logic for each script in a function, make a new file which imports all the 3 functions, and then run that script.

So if the scripts are

edureka1.py

def f1():
  ...

edureka2.py

def f2():
  ...

edureka3.py

def f3():
  ...

Then the final script()test.py which you will run is :

#!/usr/bin/python
import sys

from edureka1 import f1
from edureka2 import f2
from edureka3 import f3
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)

from edureka1 import f1
from edureka2 import f2
from edureka3 import f3

f1(str(sys.argv[1]),....)
f2(str(sys.argv[1]),....)
f3(str(sys.argv[1]),....)

Now run above script as follows −

$ python test.py arg1 arg2 arg3...............

Hope it helps!!

Thank You!!

answered Aug 10, 2020 by Niroj
• 82,880 points

Related Questions In Python

0 votes
1 answer

What's the right way to concatenate files and appending the New Line character in Python? Text or binary mode?

It seems like you're using the wrong ...READ MORE

answered Nov 13, 2018 in Python by Anirudh
• 2,090 points

edited Dec 14, 2018 by Anirudh 1,560 views
0 votes
1 answer

Need a python script to login into a website but username and password are in a txt file (Selenium automation script)

I had a similar requirement. I had ...READ MORE

answered Jan 31, 2019 in Python by Omkar
• 69,230 points
8,246 views
0 votes
1 answer

Is it possible to run a function in Python using the command line?

Suppose your file name is demo.py and ...READ MORE

answered Jun 26, 2019 in Python by Neel
• 3,020 points
999 views
–1 vote
2 answers
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,364 views
0 votes
1 answer
0 votes
4 answers

Is it possible to call one python script from another Python Script?

Try using os.system: os.system("script2.py 1") execfile is different because it is ...READ MORE

answered Dec 16, 2020 in Python by Gitika
• 65,890 points
70,104 views
0 votes
1 answer

Write code to create a list of word lengths for the words in original_str using the accumulation pattern and assign the answer to a variable num_words_list.

Hi,  num_words_list = len(original_str.split()) original_str.split() - split words in ...READ MORE

answered May 27, 2020 in Python by Niroj
• 82,880 points
3,829 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP