0

I am running Ubuntu 16.04.4. I have an executable that takes initial condition inputs from a text file, performs calculations, and generates an output file. I want to run calculations for a large number of initial conditions, so I wrote a python script (python 3.5.2 running in Spyder 3) to create the input file, run the executable, and read in the outputs.

The script seems to create the input text file just fine, but the executable does not recognize the input file unless I first open the input file, make some sort of change, save, and close it. For instance, I can open the file, delete a character, replace it with the original character, save, and everything works. This of course, defeats the purpose of automating the process. Any thoughts as to the cause?

  • Can you be more specific than "does not recognize"? One possibility is that your python script is not properly terminating the file - and that the subsequent re-save is – steeldriver May 29 '18 at 2:59
  • Have you diffed the file before and after opening and saving the file? Your text editor maybe doing something else when you save the file like removing whitespace at the end off lines etc. – rusty shackleford May 29 '18 at 7:56
  • The comment from rusty led to a solution. After diffing the two files, I found that the one not recognized by the executable was missing a newline character. Problem solved! – user292970 May 31 '18 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.