on 02-05-2017 12:23 PM
Hello,
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
go
select count(*) from syslogins
go
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:
-----------
83
(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.
Laszlo
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi https://answers.sap.com/users/27746/laszlo.html ,
Notepad++ is having issue of adding junk characters , so better to use Notepad (provided by MS) or vi(*nix default editor).
Thanks
Pankaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
HTH
Avinash
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.
Regards,
Laszlo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.