Skip to Content
avatar image
Former Member

isql generates empty output file


I am trying to connect to a Sybase ASE 15.7 data server in bash on Red Hat with isql the following way:

isql -S host.domain:port -U myLogin -P myPassword -i input.sql -o output.txt

input.sql contains the following text:

use master


select count(*) from syslogins


output.txt is being generated but unfortunately it is all empty.

If I run the exact same command in cmd.exe on Windows it generates output.txt with the actual result set:



(1 row affected)

How could I make isql work in bash so it does not generate empty output file but one with the actual result?

Permissions on input.sql are OK, it has 700 on it.

Thanks in advance.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Feb 05, 2017 at 03:44 PM

    The usual reason for an empty output file in this sort of situation is isql not seeing a valid batch terminator
    after the statement that should produce the output, causing isql to simply exit without any error. Most
    other situations result in at least some error message in the output file.

    I see that you do have a final "go" in your script, but perhaps something isn't quite right.
    The "go" must start on the first character on the line, and there should be a newline character
    after it (though there can be whitespace, comments, etc)

    Examine the input file with "od -x input.txt" to see exactly what is on the line with the final "go"

    Try adding a blank line after the final go.

    Add comment
    10|10000 characters needed characters exceeded

    • Ahhh, good reminder.

      Might be of interest to see where the input.sql file came from; Windows and *nix have different EOL characters for text files so if the file's not copied/converted properly (between Windows/*nix) then the different EOL character can cause the SQL script to behave as if there's no 'go' statement.

      As another/quick check the OP could, on linux, run 'dos2unix input.sql' (converts Windows EOL characters to *nix EOL characters) to make sure the linux version of the file has a valid EOL character after the 'go' statement.

      Alternatively, while on linux create a new file (eg, input2.sql), and submit this to isql. If this generates the desired output then the OP could run 'od -c <filename>' against both input*.sql files to see the difference in EOL characters (look for \n and \r characters).

  • Feb 05, 2017 at 03:02 PM

    Try running your isql test again but this time remove the '-o output.txt' clause; this will cause all output to go to stdout and stderr (ie, to your console window).

    With the '-o output.txt' clause removed, do you get the desired output? do you get any errors/output?

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 07, 2017 at 01:26 PM

    Hi ,

    Notepad++ is having issue of adding junk characters , so better to use Notepad (provided by MS) or vi(*nix default editor).



    Add comment
    10|10000 characters needed characters exceeded

    • Check if utilities dos2unix and unix2dos allow you to convert text file contents to the OS platform you want to use.

      This is typically the "control-M" character which is not visible when you take a dos file to unix and try to use it "as is"



  • avatar image
    Former Member
    Feb 05, 2017 at 05:30 PM

    Bret, Mark,

    Thanks very much for your comments, I appreciate it.

    You were right, the issue was with the end of line characters \r\n which is now set to \n. Should start using vi more instead of Notepad++ / SFTP on Windows :).

    Now that this works fine, I can start adding more complex code into input.sql as per my original intention.

    Thanks again.



    Add comment
    10|10000 characters needed characters exceeded