2

Alright, so I have been asked to help with this script. Basically what it needs to do is email a user if there is an error associated with an ID. Now I won't go into too much detail on that because the sql portion does that correctly. What I don't know how to do is pull out each user email from the sql individually and email them one at a time then attach the error ticket associated with it to the email body.

My KSH script as I have it now.

#!/usr/bin/ksh

# sets all environment variables
. /data/pmes/pmes/pmes_scripts/pmes_Env_Var.config

# sets the results of the .sql file to the emailBody Variable
emailBody=`sqlplus -s $USERID/$PPASSWD@$DATABASE @/data/pmes/pmes/pmes_scripts/testingmail2.sql`

# these email addresess are emailed when the script completes
MAIL_ID='emailme@yoursite.com'

(echo "$emailBody")|mailx -s "Test Email`"  $MAIL_ID

Output of echo $emailBody

aaron.heckel@yoursite.com 20140801_BR_Bob,D_PZXKGX steve.naman@yoursite.com 20140816_AM_Andrew,D_PZXKGX 

(It is basically email then the issue ID. Each item has a space in between them)

Any help would be appreciated. I'm very new with mailing and sqlplus in UNIX.

smurfguy
  • 45
  • 1
  • 6
  • 1
    This is important: what's the **actual** output of the sql call? Quote the variable and show the output: `echo "$emailBody"` – glenn jackman Sep 30 '15 at 20:04
  • The out of $emaiBody is this stuff (aaron.heckel@yoursite.com 20140801_BR_Bob,D_PZXKGX steve.naman@yoursite.com 20140816_AM_Andrew,D_PZXKGX). Basically i just take the sql and put it into the emailbody. – smurfguy Oct 01 '15 at 14:33
  • Please edit your question to add the output of `echo "$emailBody"` (with the quotes!!) with formatting. To properly handle the output of the sqlplus command, it's really important to know where the newlines and other whitespace are. I'm trying to help you, please do your part to answer my questions. – glenn jackman Oct 01 '15 at 14:39
  • Ok hopefully that is what you want. It's under Output of echo $emailBody. That is literally what I am getting from emailBody. Email then ID over and over again until there is nothing left to select. – smurfguy Oct 01 '15 at 17:01
  • Put double quotes around the variable and try again. This is the third time I've said this. – glenn jackman Oct 01 '15 at 17:28
  • Oh sorry I thought you were trying to tell me around the output. – smurfguy Oct 01 '15 at 17:37

0 Answers0