starlite79
Technical User
Hi.
I have an email and phone list that is set up like a shell script. For example, the file to be read looks similar to this:
You may ask why I would want to use awk to read a file like this when the script as is works fine (mailx -s subject $to1 > some file, for example). However, for testing on different machines, a person may want to make sure an email goes only to them, not the entire group defined by a certain variable. I would like awk to read one file containing all email and phone numbers and know when to email or send text message something only to certain people in the list. Say only Joe should get the emails, not both Joe and Jane.
Here is what I've tried so far:
The resulting email is like this:
Subject: Test
To: joe.smoe@example.com
Body: joe=joe.smoe@example.com
Of course, I don't want the body to have that line in it. What should happen is the mail program will send another file I specify.
Any suggestions?
I have an email and phone list that is set up like a shell script. For example, the file to be read looks similar to this:
Code:
#!/bin/ksh
# E-mail list
joe=joe.smoe@example.com
jane=jane.doe@example.com
to1="$joe $jane"
to2="$joe"
You may ask why I would want to use awk to read a file like this when the script as is works fine (mailx -s subject $to1 > some file, for example). However, for testing on different machines, a person may want to make sure an email goes only to them, not the entire group defined by a certain variable. I would like awk to read one file containing all email and phone numbers and know when to email or send text message something only to certain people in the list. Say only Joe should get the emails, not both Joe and Jane.
Here is what I've tried so far:
Code:
BEGIN { FS = "="
}
$1 ~ /joe/ { print | "mailx -s \"Test\" " $2 }
The resulting email is like this:
Subject: Test
To: joe.smoe@example.com
Body: joe=joe.smoe@example.com
Of course, I don't want the body to have that line in it. What should happen is the mail program will send another file I specify.
Any suggestions?