This log will be brief, a kind reminder of the little details that we all take for granted but are actually as important as the big thing.
This is the scenario: I have a Linux shell script that internally calls for the Informix dbaccess command line tool, passing a script file name as a parameter to the tool. The second script contains SQL instructions to be executed in the selected database instance. Take a look at the configuration:

As you can see in the screenshot above, it is a quite simple one. The SH file is the bash script and the sql file, despite being empty, is the SQL script to be run by dbaccess.

If we execute the more command on the sh file, we can see that some messages are echoed to the screen before and after running the sql script, and the dbaccess DATABASE sql_script.sql is precisely the instruction I want to have the database run.
So, this log originated exactly at that point when I ran the script and instead of getting an error for running an empty sql file I got this:

802: Cannot open file for run? The script has 3 lines, evidently, the error was raised when the shell tried to run the dbaccess command using the sql file. The first echo was output, we can also see the Database selected message which occurs when dbaccess database_name runs. Then, why are we seeing an error stating that the file cannot be opened?
The description for error 802 in Informix reads:
-802 Cannot open file for run.Review the filename that you specified. If it is spelled as you intended, check that it exists in the current directory or in a directory that is named in the DBPATH environment variable and that your account has read permission for it.
The screenshots show clearly that the files are where expected, they have read privileges and the name is correct.
What is the black magic behind preventing the script from running?
As I said in the beginning, sad but true, the little details are behind. What I missed saying when I began this log (on purpose) was that I typed the shell script in a Windows machine and transferred it to the Linux server using FTP. The problem is that my shell script has the EOL (end of line) terminator for Windows, not for Linux, therefore the Linux bash interpreter is unable to fully understand the script.
We can fix this directly in Linux using the dos2unix command:

Once the EOL has been adjusted to Linux, I tried running the script again:

Finally! Everything is working as expected. This log is short, indeed, however, it took me an hour to find out what the problem was. I hope this saves that hour for you.

Responder a Error en Informix dbaccess shell script: file not found – Crónicas de ProgramaciónCancelar respuesta