Re: Catch Informix error message in a shell file
Posted in 2000
Topics: Stored Procedures & SPL, Server Administration
In article <38984099.60712806@news.ca.geac.com>,
i.sokolsky@geac.com (Igor) wrote:
> Hi All
>
> I use following unix shell file to DROP and than to create Stored
> Procedure : ( cat create_sp.dat ) | dbaccess DB_NAME;
> But I getting a informix error message when Stored Procedure is not in
> db.It try to drop it, but if I run this script for first time it is
> not there yet. Is that possible to catch this error somehow and to
> give user some normal message.
Not a very clean way, I'm afraid. You can redirect the output and error
to a file, then read the file and check for the string you want to
ignore. If it's anything else, write it for the user. If it is the
error you expect, you can write the standard SNAFU message to them.
(cat create_sp.dat) | dbaccess DB_NAME >outfile 2>errfile;
while read $errline
do
...
done <errfile
--
# unrm /
ksh: unrm: not found
# man cpio
Sent via Deja.com http://www.deja.com/
Before you buy.
> Not a very clean way, I'm afraid. You can redirect the output and
error
> to a file, then read the file and check for the string you want to
> ignore. If it's anything else, write it for the user. If it is the
> error you expect, you can write the standard SNAFU message to them.
>
> (cat create_sp.dat) | dbaccess DB_NAME >outfile 2>errfile;
> while read $errline
> do
> ...
> done <errfile
Ah, let me say that this is NOT the only way, just the easiest and
quickest way for me. Someone else may have a cleaner and easier idea
using awk or tcl or somesuch. Also, unless you redirect the output to a
variable filename, you will run the risk of two people writing to the
same file twice. Another option is to redirect the output to
outfile.`date +%S` or use a counter..
--
# unrm /
ksh: unrm: not found
# man cpio
Sent via Deja.com http://www.deja.com/
Before you buy.
Use the $$ variable. $$ is the pid of the current shell, so it's guaranteed
to be unique whilever the process is running.
mars1972@my-deja.com wrote:
> > Not a very clean way, I'm afraid. You can redirect the output and
> error
> > to a file, then read the file and check for the string you want to
> > ignore. If it's anything else, write it for the user. If it is the
> > error you expect, you can write the standard SNAFU message to them.
> >
> > (cat create_sp.dat) | dbaccess DB_NAME >outfile 2>errfile;
> > while read $errline
> > do
> > ...
> > done <errfile
>
> Ah, let me say that this is NOT the only way, just the easiest and
> quickest way for me. Someone else may have a cleaner and easier idea
> using awk or tcl or somesuch. Also, unless you redirect the output to a
> variable filename, you will run the risk of two people writing to the
> same file twice. Another option is to redirect the output to
> outfile.`date +%S` or use a counter..
> --
> # unrm /
> ksh: unrm: not found
> # man cpio
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.