Send Email using Korn Shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Send Email using Korn Shell
# 1  
Old 03-26-2010
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.

Code:
 
#!/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!

Last edited by vbe; 03-26-2010 at 12:50 PM.. Reason: code tags
# 2  
Old 03-26-2010
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...
# 3  
Old 03-27-2010
Code:
#!/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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to send html email from shell script

This is my below script which is working fine as it send only plain text email. So My question is- How can I modify my below script to send this as an HTML formatted email? I want to show the text color of this expression `(echo "100*$TEST2/$TEST1" | bc -l)` as `RED` in an email and that can be... (3 Replies)
Discussion started by: raihan26
3 Replies

2. Shell Programming and Scripting

Send email from shell to users in Mysql

Hi, I need help about sending mail in linux. I have a ubuntu server with working web site, users are uploading files in one main directory (to folder inbox). With samba I shared that directory and on other mashine is Windows server and application that is reading that files and writting content to... (3 Replies)
Discussion started by: drazenmd
3 Replies

3. Shell Programming and Scripting

Help with shell script to send email once

Hi Guys, I have this script which will monitor oracle db process if up or down.And I want it to send email if it's down and the time it's back to online. However my script just keep on sending "Email Up" if the db is up or "Email Down" if the db is down.Is there any way to trap it so that it... (5 Replies)
Discussion started by: d3xt3r
5 Replies

4. Shell Programming and Scripting

Shell script to send an email from the txt file

Hi Friends, Could you guys help me out of this problem... I need to send an email to all the users and the email has to be picked from the text file. text file contains the no. of records like: giridhar 224285 847333 giridhar276@gmail.com ramana 84849 33884 venkata.ramana@gmail.com... (6 Replies)
Discussion started by: giridhar276
6 Replies

5. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

6. Shell Programming and Scripting

How to send email through shell script

Hi All, I am new to the unix , i have to deliver one script very urgently I have to write a shell script where i have i want to send email to specific email id in this script i want FROM to be parameterized and stored in a variable TO to be parameterized and stored in a variable... (3 Replies)
Discussion started by: nileshbhawsar
3 Replies

7. Shell Programming and Scripting

make un shell script to send email

Hi, Someone Knows how to obtein a chain from a unix file, but not all the line, for exemple, for this file ,obtein only 902111111 and to keep the value, this value will be used to make a mailx. NF=ALL, SUBJ= FROM: SN=CD, SE=TOPCALL, NA=, N=902111111, N=TCLFI TO: SE=FAX, NA=, C1=... (0 Replies)
Discussion started by: peybol
0 Replies

8. Shell Programming and Scripting

shell send html email

I know how to send an email with sendmail in a shell script. I know how to send an email with an attachment in a script. But im trying to send an email and need to set Content-Type to text/html and insert a file as the body and not attachment. Send email with file as attachment: ... (4 Replies)
Discussion started by: Ikon
4 Replies

9. Shell Programming and Scripting

How to write a shell script to send an email to an id

Hi all, I want to know how to send an email using shell script ..... I tried a command call mail but it did not work.. Please any one reply.. With example if you know thanks.. Madhu (4 Replies)
Discussion started by: madhumathikv
4 Replies

10. UNIX for Dummies Questions & Answers

Shell to run query, encrypt and send email

Hello To do : 'automate the process of generating report and send it to client every 15 days after encrypting the report file' Did so far : - generate Java program to encrypt the file. - generate SQL query to run the report. Is there any body who can help me to go further ? ... (7 Replies)
Discussion started by: cub
7 Replies
Login or Register to Ask a Question