0

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?

6
  • 1
    have you manually tried something like test.py -i 1.in.xml -o out_1 -x 1.in -c 56 ? would help you narrow down the problem Commented Mar 16, 2011 at 16:14
  • Show us the test.py code Commented Mar 16, 2011 at 16:19
  • Yes I did it manually... It runs fine when I run the python code with a single input file!!! Commented Mar 16, 2011 at 16:29
  • then id have to guess new doesnt have the value you expect. can you try to echo out new right after you assign to it in each iteration? Commented Mar 16, 2011 at 16:31
  • tried that also.... It gives me the value that I want it to take !!! Commented Mar 16, 2011 at 16:43

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I am opening the file as you suggested!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.