Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

expr: 0402-050 Syntax error while doing arithmatic operation on the variable containing the sql que

user12195658Aug 26 2016 — edited Aug 26 2016

Dear There,

i am creating a shell scripts which mails us in case the production database growth is more than 300mb as we usually face space crunch issue.

our OS is Solaris Sun sparc 10 64bit.

in this scripts there are two variable which will be storing the current date free space and previous date free space in mb.

if the difference of the two is more than 300 mb it should generated an alert through mail.

i am able to store the value of twp scripts but when i try to take the difference of these two variable value i am getting error expr: 0402-050 Syntax error

not able to figure out where the issue is.?

below is the script:

export PATH=/usr/bin:/usr/sbin

        if [ -f /usr/bin/less ]; then

        export PAGER="/usr/bin/less -ins"

        elif [ -f /usr/bin/more ]; then

        export PAGER="/usr/bin/more -s"

        fi

        case ${SHELL} in

        *bash)

        typeset +x PS1="\u@\h:\w\\$ "

        ;;

        esac

        export ORACLE_HOME=/oracle11/home/app/oracle11/product/11.2.0/dbhome_1

        export ORACLE_BASE=/oracle11/home/app/oracle11

        export TNS_ADMIN=/oracle11/home/app/oracle11/product/11.2.0/dbhome_1/network/admin

        PATH=$PATH:$ORACLE_HOME/bin

        LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

        export LD_LIBRARY_PATH

        today=`sqlplus -s  system/*****@PODBCGI1  <<endl

        set pagesize 0 feedback off verify off heading off echo off;

        SELECT round(FREE_SPACE) FROM DB_GROWTH WHERE trunc(SYSDATE) = trunc(sysdate);

        exit

        endl`

        yesterday=`sqlplus -s  system/*****@PODBCGI1  <<endl

        set pagesize 0 feedback off verify off heading off echo off;

        SELECT round(FREE_SPACE) FROM DB_GROWTH WHERE trunc(SYSDATE) =trunc(sysdate-1);

        exit

        endl`

        d=`expr $today - $yesterday` ===> its giving error here

        echo $d

thanks

This post has been answered by John Spencer on Aug 26 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 23 2016
Added on Aug 26 2016
10 comments
1,499 views