LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   bash/ksh variables question (http://www.linuxquestions.org/questions/programming-9/bash-ksh-variables-question-352172/)

tpe 08-11-2005 07:49 AM

bash/ksh variables question
 
Dear All,
I have a ksh script (main.ksh) that reports the existence or not of specific files. The script is working fine, but I would like to have a better error report mechanism. Thus, I have created 3 e-mail templates (plain text files) that I would like to send at specific e-mail accounts regarding the error code.

The 3 e-mails are different, and I would prefer to have them as plain text files that the script reads them, change the variables and send it.

As an example, here is one of the 3 files:

Code:

This is the report script.
You received this e-mail because file check failed to run at ${RUNDATE}/${RUMONTH}@${RUNTIME}:${RUNMINUTE}.

The file check is scheduled to run again at ${RUNDATE}/${RUMONTH}@${NEWRUNTIME}:${RUNMINUTE}.

Now, what I want, is the "main.ksh" script read that file, substitute the variables and send the e-mail. What I need to help me is the variables substitution. Can anyone help me?

Thank you in advance,
Peter

jim mcnamara 08-11-2005 09:23 AM

Why not just do this in the script itself? (this reduces issues of debugging and maintenance as well)
Code:

echo "You received this e-mail because file check failed to run at ${RUNDATE}/${RUMONTH}@${RUNTIME}:${RUNMINUTE}.

The file check is scheduled to run again at ${RUNDATE}/${RUMONTH}@${NEWRUNTIME}:${RUNMINUTE}. " | sendmail someuser@somewhere.org


tpe 08-11-2005 09:39 AM

That's the easy way, but that script wil be installed to a production server. I cannot change it any time I would like. Thus, (and the fact that I will learn something new :) ) , I have to go the hard way.

In case no one answer, I will go the easy way :( .


All times are GMT -5. The time now is 05:08 AM.