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 problemCommentedMar 16, 2011 at 16:14
  • Show us the test.py code
    – Nix
    CommentedMar 16, 2011 at 16:19
  • Yes I did it manually... It runs fine when I run the python code with a single input file!!!CommentedMar 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?CommentedMar 16, 2011 at 16:31
  • tried that also.... It gives me the value that I want it to take !!!CommentedMar 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.

1
  • I am opening the file as you suggested!CommentedMar 16, 2011 at 16:26

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.