mailx and awk- didn't find an answer KSH


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers mailx and awk- didn't find an answer KSH
# 1  
Old 01-26-2005
mailx and awk- didn't find an answer KSH

Hi folks,

My input file's content:
You are line1
You are line2
You are line3
etc...


I need to write a script that for every line, it will send an e-mail and the body will hold the line:

Output(The e-mail that will be sent):
First e-mail: To: aaa Subject: bbb Body:You are line1
Second e-mail: To: aaa Subject: bbb Body:You are line2
and so one..

This is a part of ksh script and I find it hard to do it:

Can anyone assist me?

I wrote:

cat inputFile| awk '{print $0 >! tmp};{mailx -s 'Subject' 'aaa@hotmail.com' < ${tmp}") }'

But it doesn't work.

Thanks
# 2  
Old 01-26-2005
Code:
exec < file1
while read line
do
    echo $line > tmp
     mailx -s 'subject' abc@xyz.com < tmp
done

# 3  
Old 01-26-2005
try something like this:
Code:
#!/bin/ksh
# mailx example
# $1 is the input file name
while read record
do
     mailx -s 'Subject' 'aaa@hotmail.com' < `echo $record`

done < $1
exit

# 4  
Old 01-26-2005
Thanks alot folks you are the best!!!! :)

Smilie
Thank you
# 5  
Old 01-26-2005
Another question, if you don't mind

I am working on solaris machine.

Can I change the e-mail in From: header

Currently it sends e-mail From: dev1@domain.com
Instead, I would like it to be From: SysAdmin

Thanks in advance.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Didn't find a suggestion thread

An 'addition' to the "Homework & Classes" requirements.. As i am someone without paper, i just figured i got tempred reading such a question. To avoid such 'feelings' in future, i'd be thankfull if the 'kind & definition of the course' would be required too. As in (i dont know about proper... (2 Replies)
Discussion started by: sea
2 Replies

2. Shell Programming and Scripting

Number comparison in ksh on mac with -lt is giving wrong answer

I am trying to run following script in ksh on darwin 11.4.2: freeSpace=2469606195 spaceNeeded=200 ] && echo "no space" || echo "space available" ] && echo "no space" || echo "space available" "-lt" is giving wrong answer as "no space" Whereas '<' works fine. When I change the freespace... (4 Replies)
Discussion started by: sabitha
4 Replies

3. Shell Programming and Scripting

KSH - mailx - Redirect the undelivered mail

Hi, I need to create one KSH which will send mail to set of recipients using "mailx" command like below. mailx -s "Test mail" "test@yahoo.com, test@gmail.com" <$output.txt The recipients are in different domains (like yahoo, gmail, etc.). My requirement is, if any mail is undelivered,... (1 Reply)
Discussion started by: Matrix2682
1 Replies

4. Shell Programming and Scripting

awk: assign variable with -v didn't work in awk filter

I want to filter 2nd column = 2 using awk $ cat t 1 2 2 4 $ VAR=2 #variable worked in print $ cat t | awk -v ID=$VAR ' { print ID}' 2 2 # but variable didn't work in awk filter $ cat t | awk -v ID=$VAR '$2~/ID/ { print $0}' (2 Replies)
Discussion started by: honglus
2 Replies

5. UNIX for Advanced & Expert Users

hi Please try to find an answer to this

Hi Friends, I have siebel installed in one of my aix machines and while opening a file it gives below error. $ vi SmSiebelSSO.conf History file has no read permission. q Please note the file has rwxr-xr-x for oracle:dba and i am trying to open using oracle id itself which is the owner... (1 Reply)
Discussion started by: DJ2176
1 Replies

6. Shell Programming and Scripting

mailx: concatenating strings for message body (KSH)

Hi all, Think this is a pretty simple problem, but I've been thinking about it for a few days. Let's say that I'm going to have to output the contents of a file as the body of a mailx message. I'll probably do this: cat <filename> | mailx <extra commands> However, how do I go about doing... (1 Reply)
Discussion started by: rockysfr
1 Replies

7. Shell Programming and Scripting

Mailx in shell script (KSH)

Greetings all, I'm pretty new to the use of mailx, having been using mutt most of the time. I'm interested to know how I can use mailx within a shell script to send out a formatted email with the following criterion: 1. My recipient's address is abcdef1000@gmail.com 2. The message body is... (2 Replies)
Discussion started by: rockysfr
2 Replies

8. UNIX for Advanced & Expert Users

mailx on ksh revisited

I have read through all documents in FAQ and have run into an issue with sending an email with body message text and an email attachment. I have included what I have thus far and I can get the message body to send in the email to work only. I cannot understand the uuencode even after I read the... (5 Replies)
Discussion started by: tekline
5 Replies

9. Shell Programming and Scripting

ksh : using mailx and attachments

Hi I want to use mailx command to send a message included more than one file. I tried to use uuencode in pipe but it could only generate one file. I would avoid using an archive file :p Thanks to read you. Mathieu (2 Replies)
Discussion started by: madmat
2 Replies

10. AIX

Cannot find answer - stop queueing messages?

My root mail fills up very quickly because we have hundreds of remote printers and whenever a job is deleted, moved or a printer is down, up, sidways (jk) the queueing system drops root and email. It fills up super fast and is causing a problem. Rembak is the backend but i cannot find a way... (2 Replies)
Discussion started by: albertaguirre
2 Replies
Login or Register to Ask a Question