Hi all CentOS users, I have writing shell script for check oracle processes in real time and alert with e-mail. I read script like below NUMBEROFPRO=/oracle/10.2.0/db_1/bin/sqlplus / as sysdba <<EOF1 |grep processes|awk '{print $2}' SELECT resource_name,current_utilization,limit_value FROM V\$RESOURCE_LIMIT WHERE RESOURCE_NAME IN ('processes','sessions'); quit EOF1 if [ $NUMBEROFPRO > 150 ] then /bin/mail -s "Processes number bigger then 150 !!" myemailadres<<EOF Contact your system administrator. EOF fi Script print value correctly on screen but NUMBEROFPRO have empty value in script.How can i take and print NUMBEROFPRO value from above query ? Thanks for all.
Semih Gokalp wrote:> Script print value correctly on screen but NUMBEROFPRO have empty > value in script.How can i take and print NUMBEROFPRO value from above > query ?By putting `` or $( ) around the call. Ralph -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available URL: <http://lists.centos.org/pipermail/centos/attachments/20090130/dc8ceffb/attachment-0003.sig>
On Jan 30, 2009, at 8:52, Ralph Angenendt wrote:> By putting `` or $( ) around the call.You can also eliminate the grep altogether: NUMBEROFPRO=/oracle/10.2.0/db_1/bin/sqlplus / as sysdba <<EOF1 | awk '/processes/ {print $2}' SELECT resource_name,current_utilization,limit_value FROM V\ $RESOURCE_LIMIT WHERE RESOURCE_NAME IN ('processes','sessions'); quit EOF1 Cheers, Alfred
Hi, On Fri, Jan 30, 2009 at 08:40, Semih Gokalp <semihgokalp at gmail.com> wrote:> if [ $NUMBEROFPRO > 150 ]This is wrong, should be [ $NUMBEROFPRO -gt 150 ] instead. HTH, Filipe
On Fri, 30 Jan 2009, Filipe Brandenburger wrote:> This is wrong, should be [ $NUMBEROFPRO -gt 150 ] instead.or for those who are used to being burned: [ 0$NUMBEROFPRO -gt 150 ] -- Russ herrold
On Fri, Jan 30, 2009 at 13:59, R P Herrold <herrold at centos.org> wrote:> or for those who are used to being burned: > [ 0$NUMBEROFPRO -gt 150 ]Still going to explode if $NUMBEROFPRO contains spaces. Putting in double quotes will not help you either, since it will complain about it not being numeric... Doing math with the shell is always tricky, almost never robust... Filipe