[Info-Ingres] Running Ingres SQL commands from a shell script?
Robert Allely
allelyr at axis-intermodal.co.nz
Wed Apr 25 21:27:34 CDT 2007
Hi Dan
It will be interesting to see what comes out of your question... We use
a shell script
Which the sql commands are piped thru, which reads its own output to see
if any lines
Start with E_
This allows the calling scripts to stop if the sql fails in any way at
all.
uid=`/lbin/id -un`
sqlfl=/var/tmp/sql.$uid.$$
echo sql "$@" ... $sqlfl
sql "$@" > $sqlfl 2>&1
code=$?
cat $sqlfl
if [ $code -ne 0 ] ; then
exit $code
fi
if [ `egrep 'E_POAERR|^E_' $sqlfl | wc -l` -gt 0 ] ; then
exit 1
fi
Robert
-----Original Message-----
From: info-ingres-bounces at kettleriverconsulting.com
[mailto:info-ingres-bounces at kettleriverconsulting.com] On Behalf Of Dan
Stromberg
Sent: Thursday, 26 April 2007 1:33 p.m.
To: info-ingres at kettleriverconsulting.com
Subject: [Info-Ingres] Running Ingres SQL commands from a shell script?
Hi folks.
Is there any good way, from a shell script, to run SQL commands against
Ingres (perhaps via ingres' terminal monitor), and to get a useful exit
status from the SQL statements back to the calling shell?
I realize I could use something like python with an ODBC interface, but
1) that seems kind of heavyweight for what I want to do and 2) I don't
think I'll be able to get permission to put an ODBC interface -on- the
machines in question. It's pretty much whatever comes with CentOS 4.4
or not at all for this project.
Ideal might be to have any exit stati and'd or or'd together (dare I
say, at the caller's discretion?), or to have an array of exit stati
kind of like bash's $PIPESTATUS array, except for a chronology of
statements, not concurrent-but-chained-together statements.
If I must, I could run the SQL statements (the ones with side effects,
at least) one a time though.
Any suggestions?
Thanks!
_______________________________________________
Info-Ingres mailing list
Info-Ingres at kettleriverconsulting.com
http://www.kettleriverconsulting.com/mailman/listinfo/info-ingres
***
This e-mail is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender at Ports of Auckland Limited.
***
More information about the Info-Ingres
mailing list