I am writing a script to run a few different PHYLIP programs and have encountered something strange: I am temporarily unable to rename output files immediately after running a PHYLIP program. Here is some code that demonstrates the problem and my hacked solution:
###### RUN DNAML ON INPUT FILE ###### # CREATE INPUT FILE mv infile data.dat # CHANGE FILE NAME FROM "infile" echo data.dat > input # CREATE FILE, "input" WITH FILE NAME echo I >> input # ADD OPTION "I" TO SET FORMAT TO "SEQUENTIAL" echo Y >> input # ADD OPTION "Y" TO ACCEPT CHANGES # RUN DNAML /Users/kendalls/phylip-3.695/exe/dnaml < input > screenout & echo "Ran Dnaml" # CHANGE OUTPUT FILE NAMES #mv outfile outfile.dnaml mv outfile outfile.dnaml # THIS COMMAND FAILS AND RETURNS AN ERROR MESSAGE IF THE LINE ABOVE IS COMMENTED OUT mv outtree outtree.dnaml
The error message this produces is:
mv: rename outfile to outfile.dnaml: No such file or directory
This error only appears for the first renaming command after running a PHYLIP program and I get an identical error if I try to rename the "outtree" file first. I have also tried using the "cp" command instead of "mv" but get the same error. Furthermore, this error appears with every PHYLIP program I have tried.
My best guess for why this happens is that somehow the PHYLIP program keeps the output files open after it finishes running and my initial attempt to renaming the file coerces PHYLIP program to close the output files. Does anyone know for sure how to explain this bug? Also welcome any suggestions on how to re-write my script.