Binary Operator expected while executing the below shell script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Binary Operator expected while executing the below shell script.
# 1  
Old 04-15-2013
Binary Operator expected while executing the below shell script.

Hi Experts,

Iam bit poor in shell scripting,
Here my requirement is for generating an alert where the oracle database db_recovery_file_dest_size usage. If it reaches beyond 80% should recieve an alert through an email.

Want to schedule this alert in cron.
Code:
#!/bin/bash
. /home/oracle/prod.env
echo " "
echo =======================================================================
echo archive_usage.sh:  $ORACLE_SID
echo To know the Archive/Db_recovery_area usage
date +"%A, %B %e, %r"
echo -----------------------------------------------------------------------
status=$(sqlplus -S system/PWD@$ORACLE_SID << ENDINP
set feedback off
set hea off
set verify off
SELECT METRIC_VALUE FROM SYS.DBA_OUTSTANDING_ALERTS where reason like '%db_recovery_file_dest_size%'
/
exit
ENDINP)
status=`echo $status`
echo "Archive Area usage is:" $status
if [ $status >= 80 ]; then
   mailx -s "PROD - Archive Area Usage is growing" "mjcprasad2000@gmail.com"
      Production PROD ARCHIVE Area is above 85%!!
   exit 1
else
mailx -s "PROD - Not in Thresholds" "mjcprasad2000@gmail.com"
   exit 0
fi


Please help me in sorting out this issue. Smilie

Thanks & Regards,
-----------------
Jagadish.
Oracle Apps DBA.

Last edited by Franklin52; 04-15-2013 at 08:12 AM.. Reason: Please use code tags for code and data samples
# 2  
Old 04-15-2013
Will this query
Code:
SELECT METRIC_VALUE FROM SYS.DBA_OUTSTANDING_ALERTS where reason like '%db_recovery_file_dest_size%'

returns only one row?

rewrite status=`echo $status` to status=$(echo "$status")
# 3  
Old 04-15-2013
I don't have a database to test with, but at least one problem in your script is that in the command:
Code:
if [ $status >= 80 ]; then

the >= performs a string comparison (where 9 > 80 and 100 < 80 and 1 < 80). To perform a numeric comparison, try:
Code:
if [ $status -ge 80 ]; then

# 4  
Old 04-15-2013
Quote:
Originally Posted by PikK45
Will this query
Code:
SELECT METRIC_VALUE FROM SYS.DBA_OUTSTANDING_ALERTS where reason like '%db_recovery_file_dest_size%'

returns only one row?

rewrite status=`echo $status` to status=$(echo "$status")
Yes, it returns 1 value.

Still it failed with same error.

Regards,
Jagadish.
# 5  
Old 04-15-2013
Code:
status=`echo $status`

Isn't that redundant?
# 6  
Old 04-16-2013
Quote:
Originally Posted by Jagadish m
Yes, it returns 1 value.

Still it failed with same error.

Regards,
Jagadish.
What was the error??
# 7  
Old 04-16-2013
Quote:
Originally Posted by Jagadish m
Yes, it returns 1 value.

Still it failed with same error.

Regards,
Jagadish.
Before you said you had an issue (and didn't say what it was other than that you were trying to run your script in cron); now you're saying you're getting an error. Exactly what error(s) are you seeing? Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Conditional binary operator expected Error

Hi, Below is my code where i m trying to grep for name>$servername in manages*.tmp files servername="serv1" set manages*.tmp if ; then However, i get the below error at the if condition: Can you please suggest how can i fix the problem. (3 Replies)
Discussion started by: mohtashims
3 Replies

2. UNIX for Beginners Questions & Answers

Binary operator expected

Hi Team, I just started to learn shell scripting and i got this script from an online book and tried to run in my terminal. But it throws error message. echo $0 -bash echo $UID 501 cat check_rootuser.sh #!/bin/bash # Run as root, of course. LOG_DIR=/var/log ROOT_UID=0 # Only users... (4 Replies)
Discussion started by: SelvaKumarq
4 Replies

3. AIX

Script is not executing as expected when I schedule it in cron

Hi, I have a shell script which fetches the MRP status and the LAG status. When I execute it manually like, sh <script_name>, it fetches the output as expected, but when I schedule through crontab, it's not working as expected. Any help would be really appreciated. Here is the code... (3 Replies)
Discussion started by: Nagaraj R
3 Replies

4. Shell Programming and Scripting

Binary operator expected Error

Here is line number 59 of my script 59 if ; thenI get the following error at this line. Can you please explain why ? (1 Reply)
Discussion started by: mohtashims
1 Replies

5. Shell Programming and Scripting

Help - binary operator expected error

Hello Unix forum. I'm encountering the following error "binary operator expected error" and I cannot seem to solve the issue. I have the following source files to process: CPA_LOOKUP_dat.lst PROFILE_TXN__dat.lst TRANSACTION_CODE_dat.lst PROFILE_TXN_OUT_OF_BALANCE_dat.lst ... (2 Replies)
Discussion started by: pchang
2 Replies

6. Shell Programming and Scripting

bash script error with binary operator expected.

Hello, I am not sure, where I am missing in the scirpt, I am trying to grep few users from /etc/passwd file and if exists, I added line to echo as user exist, if not create it. #!/bin/bash for vid in v707 z307 z496 z163 z292 ; do if then echo " $vid User exists " else ... (2 Replies)
Discussion started by: bobby320
2 Replies

7. Linux

Binary operator expected

hi i'm trying to do program that counts the total no of words from files from a directory and all it's subdirectories.ang i get the binary operator expected error at line 7 and line 12.can you please help me with this as quick as possible? if test -d $1 then sum=0 for name in $1/* do... (2 Replies)
Discussion started by: marian
2 Replies

8. Shell Programming and Scripting

Binary operator expected

Within my script, there is this following if, then statement. It basically looks for files in a directory that match a certain naming convention (bingofile*.DAT) and are non empty files and moves these files to a diff. directory. The script works okay if there is only one file matching the search... (4 Replies)
Discussion started by: basisvasis
4 Replies

9. UNIX for Advanced & Expert Users

executing script by cron doesnt give me expected result

Hi frnds... I m facing very irritating problem already waisted my 2 days.. I have a following script..( i am pasting only the main code) ftp -ivn 213.194.40.77 <<FTP user $user $password binary cd $FileDir/out lcd $localpath get $file rename $FileDir/out/$file $FileDir/tmp/$file... (1 Reply)
Discussion started by: clx
1 Replies

10. Shell Programming and Scripting

binary operator expected error

It is erroring for : binary operator expected on the if line. Any suggestions? Thanks in advence. (7 Replies)
Discussion started by: apps_user
7 Replies
Login or Register to Ask a Question