Possible to set field separator on command line dbaccess
Posted in 1996
Topics: Stored Procedures & SPL, Server Administration, Platform-Specific Issues
Hi all,
I've been battling with this problem and have had no luck!
I am trying to grab a query from the command line and redirect it to a file in the hopes
that I can delimit the file that dbaccess returns
I have it running on a Sun with Solaris 2.4 and Informix 5.x
The script (not exact model) looks something like this:
>!#/bin/sh
>#
>#
>dbaccess databasename << EOF > /tmp/outputfile
>
>select field1, field2, from table where field1 like "foobar%">
>EOF
So, if I run the script above, named "clueless", from the command line like so:
thor% clueless
I get an output file that looks something like this:
(added \\n for clarity)
foobar1 ABC \\n
foobar12 \\n
foobar1233 ABC
foobar12345 DEF
foobar124556 DEF
foobar2545 \\n
foobar23456 \\n
foobar23677 \\n
foobar2324 \\n
foobar22354 \\n
So, the problem (at last) is that I cannot tell when field 2 is null in the output without a field separator of some kind because perl and awk (yes, hokey but works for this) don't work well without a *consistent* separator of somesort. (Splitting on white space in perl would not work for this reason)
Any fixes?!?!
I am in urgent need!
Please write to me or post to the group.
Matt Silveira
msilveir@campus.mci.net