Send Email using Korn Shell

Hi All,

I need assistance is sending email out using korn shell

Steps,
1- Count number of records in database.
2- if count is more than 2000
3- send email to user else if less then 1999 exit out.

Here is my script and is not exiting out and need to press .DOT and Enter command to get out of the script then it sends out email.

 
#!/bin/ksh
 
VALUE=$( sqlplus -s username/password <<EOF
 set heading off;
 set serveroutput on;
 select count(*) from <Table_NAME>;
 quit
EOF)
size=2000
if  [[ $VALUE -gt $size ]]; then
mail -s "Table_name count is greater then 2000" email_user@xxx.com ;
else
echo "All clear.."
exit
fi;
 
  • How can the script comes out gracefully.

Please asistance.

Thank you!

Are you not missing a ; after quit ?

---------- Post updated at 18:04 ---------- Previous update was at 17:02 ----------

In your SQL part (before EOF) that is...

#!/bin/ksh
VALUE=$( sqlplus -s username/password <<EOF
 set heading off;
 set serveroutput on;
 select count(*) from <Table_NAME>;
 quit
;
EOF
)
size=2000
if  [ "$VALUE" -gt $size ]; then
  # mail need input, /dev/null very short
  mail -s "Table_name count is greater then 2000" email_user@xxx.com < /dev/null
  # or
  echo "some ..." | mail -s "Table_name count is greater then 2000" email_user@xxx.com 
else
  echo "All clear.."
fi