-1

I have a python script that I'd like to run in bash for loop in parallel. Python script takes multiple arguments as inputs via sys.argv[x]. For example, I'd like to run in bash for loop these lines:

python py_script.py a b c &
python py_script.py d e f &
python py_script.py g h i

How could I accomplish this? Thank you in advance.

Rok Petric
  • 75
  • 3
  • 9

1 Answers1

0

What do you want achieve when running this program? If you want those files to open/run i can show you a method but otherwise i don't know. Sorry :(

Heres how to run a .py file:

from subprocess import call # Importing the call function

call(["python", "file.py"]) # Calling the file to open
  • I'd like to have some user friendly script in similar form to this: args = [ [a,b,c], [d,e,f], [h,g,i] ] for arg in args; do python py_script.py arg & done Unfortunately this does not work. – Rok Petric Aug 02 '20 at 11:41
  • 1
    okay i'll try and find a solution to your question :) – Python_user_3 Aug 02 '20 at 14:29