user638501
user638501

Reputation: 41

Shell script to run Python program with command line arguments

I have some files in a directory which are input files for my python script:

<1.in>
<1.in.xml>
<2.in>
<2.in.xml>
<3.in>
<3.in.xml>
...
..
.

I have the following till now:

for i in $(ls dir/*.in)
do
        new = ${i%%.in}
        test.py -i $new.in.xml -o out_$new -x $new.in -c 56
done

When I run this, it does not create an output file (which is defined with -o option). The error is :

IOError: [Errno 2] No such file or directory

Any suggestions?

Upvotes: 0

Views: 513

Answers (1)

freegnu
freegnu

Reputation: 813

Make sure you are opening the file for output as open(file_name, 'w') or else the file will not be created.

Upvotes: 1

Related Questions