linux - how to direct a sh script to run a python script? -


i wrote python script calls 2 files perform calculations , asks name new file place calculation in code runs this:

python code.py in_file1 in_file2 outfile 

now, have several files need same calculation , names change last numbers, wanted script takes different needed files in folder performs python script , name outputs changing las number according given in_file1 (infield_2 not change).

i tried simple not working

#!/bin/bash python code.py in_file[19]* infile_2 outfile[19]* 

i error usage of python saying usage: python code.py [-h] in in2 out unrecognized arguments

i know sure code.py works, wanted spare 1 file @ time. thank you. new in python , linux, appreciate can give.

you can in :

import os  name = "in_file%d" in range(1, 21):     os.system("python code.py in_file{} in_file2 outfile{}".format(i, i)) 

this works following, os library calling outputted strings:

>>> in range(1, 21): ...     "python code.py in_file{} in_file2 outfile{}".format(i, i) ...  'python code.py in_file1 in_file2 outfile1' 'python code.py in_file2 in_file2 outfile2' 'python code.py in_file3 in_file2 outfile3' 'python code.py in_file4 in_file2 outfile4' 'python code.py in_file5 in_file2 outfile5' 'python code.py in_file6 in_file2 outfile6' 'python code.py in_file7 in_file2 outfile7' 'python code.py in_file8 in_file2 outfile8' 'python code.py in_file9 in_file2 outfile9' 'python code.py in_file10 in_file2 outfile10' 'python code.py in_file11 in_file2 outfile11' 'python code.py in_file12 in_file2 outfile12' 'python code.py in_file13 in_file2 outfile13' 'python code.py in_file14 in_file2 outfile14' 'python code.py in_file15 in_file2 outfile15' 'python code.py in_file16 in_file2 outfile16' 'python code.py in_file17 in_file2 outfile17' 'python code.py in_file18 in_file2 outfile18' 'python code.py in_file19 in_file2 outfile19' 'python code.py in_file20 in_file2 outfile20' >>>  

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -