How to call mail id from different file in shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to call mail id from different file in shell script?
# 1  
Old 03-10-2013
How to call mail id from different file in shell script?

Hi Team,

Please can anyone tell me how to call mail ids from different file in shell script.

For Example:
=========
Code:
export MAILX=/bin/mailx

Code:
export MAIL_DBA=xxx@gmail.com,yyy@gmail.com,zzz@gmail.com

sendalertmess()
{
MESSAGE="ALARM"
echo $MESSAGE | MAILX -s "uname -n :Oracle error"
}
sendalertmess;


exit;



Instead of giving the mail ids directly. How can I get the mail ids from different file in linux shell script.

Please help me this.

Even i tried to give like this in the script as below. But it didn't work.

Code:
export MAIL_DBA=\home\abc\mailid.txt



content of the mailid.txt
Code:
xxx@gmail.com

Code:
yyy@gmail.com
zzz@gmail.com


Thanks in Advance,

Regards,
Indu

Last edited by indira_s; 03-11-2013 at 05:49 AM.. Reason: code tags
# 2  
Old 03-10-2013
You can do it by including the file. do this after shebang line

. /dir/filename

the file "filename" should have entry as below

MAIL_DBA=xxx@gmail.com,yyy@gmail.com
# 3  
Old 03-10-2013
Try reading from your mailid.txt line by line, adding each entry read to the MAIL_DBA variable, finally removing the leading comma:
Code:
$ while read; do MAIL_DBA=$MAIL_DBA,$REPLY ; done < mailid.txt; MAIL_DBA=${MAIL_DBA:1}; echo $MAIL_DBA
xxx@gmail.com,yyy@gmail.com,zzz@gmail.com

This User Gave Thanks to RudiC For This Post:
# 4  
Old 03-10-2013
Or use paste command:
Code:
MAIL_DBA=$( paste -s -d"," /home/abc/mailid.txt )

This User Gave Thanks to Yoda For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check file if not found send mail if exit call second script

I need to check my script and change to working mode. currently it was not sending the mail and exit without calling the second script. I need to check the file is present ="/home/Rvtools/test.csv" if this file not found after the time retry send mail file not found If the file exit run the... (2 Replies)
Discussion started by: ranjancom2000
2 Replies

2. Shell Programming and Scripting

Shell script to call sql file

hi , the below script contains sql query and after executed it sends the output of the query (output.txt) to an email body with conditional subject line based on the output of all_counts_match.txt. i want to make this script generic so that it can accept the sql file as parameter and can... (5 Replies)
Discussion started by: itzkashi
5 Replies

3. Programming

Writing a UNIX shell script to call a C function and redirecting data to a .txt file

Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far: #include<stdio.h> #include<string.h>... (2 Replies)
Discussion started by: bjhjh
2 Replies

4. Shell Programming and Scripting

Need help to write to log file whether the shell script call pass fail

I have the below script triggered daily at 330am in the morning, since last 7 days job not writing anything to database. below impala shell calling shell file which has sql , it is extracting data and loads to a flat file txt file. which is going wrong for last 1 week. need help, echo... (2 Replies)
Discussion started by: cplusplus1
2 Replies

5. Shell Programming and Scripting

Need Help: Shell script to call sql session with variables stored in .txt file

Hi, I need help in writing a shell script which can read data from a text file (Cancel_ID.txt) and then calls sqlplus session (Cancel.sql) with the first line parameter of the text file ("0322600453") till all rows are not completed. ... (4 Replies)
Discussion started by: Khan28
4 Replies

6. Shell Programming and Scripting

Need to write shell script for my .sql file call

Hi Guys, I need to write a simple shell script which will generate a .csv file/report by calling .sql file inside a shell script. Can somebody help me on this. Thanks in advance! Regards, LK (7 Replies)
Discussion started by: lakshmanraok117
7 Replies

7. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

8. Shell Programming and Scripting

Shell script to monitor new file in a directory and mail the file content

Hi I am looking for a help in designing a bash script on linux which can do below:- 1) Look in a specific directory for any new files 2) Mail the content of the new file Appreciate any help Regards Neha (5 Replies)
Discussion started by: neha0785
5 Replies

9. Shell Programming and Scripting

Shell script for creating log file and sending mail?

Hi , I am trying to create shell script which will help me to compare file name in two folder. There is a multiple file store in 2 folder.I want to compare that with the name. If all the file are same then send a mail that "all date is same" if not then create one log file which contain... (4 Replies)
Discussion started by: san_dy123
4 Replies

10. Shell Programming and Scripting

attaching file in mail command from shell script

Hi all, Currently in shell script i am using the following command to send mail echo "Certain assets are not loaded properly. PFA the result of the DataLoad" | mail -s "Weekly DataLoad - Failure Notification !!" $MAILINGLIST I need to attach a file along with that. How should i handle this... (7 Replies)
Discussion started by: ananthi_ku
7 Replies
Login or Register to Ask a Question