Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i email a selected option from my menu

Status
Not open for further replies.

grapes12

Technical User
Mar 2, 2010
124
ZA
I select the option, the report is being emailed..but its two options emailing one report how can i fix...
here is my
code
!/bin/ksh
WORKDIR=/u1/home/ops
SPOOLFILE=/u1/home/ops/takeondate.csv
LOGO="Users Takeon/Expired"
LIST="graham.goliath@macsteel.co.za,bernard.james@macsteel.co.za,pav.bedasie@macs
teel.co.za"

Displaymenu () {
clear
echo `date`
echo
echo "\t\t\t\t" $LOGO
echo
echo "\tSelect Option:"
echo
echo "\t\t\t [1] Run User Takeon Report "
echo "\t\t\t [2] Run User Expired Report "
echo "\t\t\t [3] Exit Program "
echo
echo "Enter option then ENTER to continue: \c"
}
PressEnter () {
echo Press Enter
read x
}
# A function for each of the menu picks

report_Takeon()
{
echo " Executing Run Takeon Report "
do_takeon
echo " Enter email address then enter to continue: \c"
read EMAIL
echo $EMAIL
do_email
PressEnter
}

report_Expired()
{
echo "Executing Run Expired Report"
do_expired
echo " Enter email address then enter to continue: \c"
read EMAIL
echo $EMAIL
do_email
PressEnter
}

do_takeon()
{
sqlplus -s mac/mac789 <<ENDOFSQL
@${WORKDIR}/takeondate.sql
exit;
ENDOFSQL
}
do_expired()
{
sqlplus -s mac/mac789 << ENDOFSQL
@${WORKDIR}/expirydate.sql
exit;
ENDOFSQL
}
do_email()
{
echo "Emailing report now"
SUBJECT="User Takeon/Expiry report"
#TO=graham.goliath@macsteel.co.za
(
cat $SPOOLFILE
) | /usr/local/bin/mutt -s "$SUBJECT" -a $SPOOLFILE $EMAIL
}
while true
do
Displaymenu
read answer
case $answer in
1) report_Takeon ;;
2) report_Expired ;;
3) break ;;
esac
done
clear
/code
help would be much appreciated
 
Perhaps this ?
...
do_takeon()
{
SPOOLFILE=$WORKDIR/takeondate.csv
...
do_expired()
{
SPOOLFILE=$WORKDIR/expired.csv
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

Additionally two minor notes :
Code:
echo `date`
Code:
date
Code:
[teal]([/teal]
cat [navy]$SPOOLFILE[/navy]
[teal])[/teal] [teal]|[/teal] /usr/local/bin/mutt -s [green][i]"$SUBJECT"[/i][/green] -a [navy]$SPOOLFILE[/navy] [navy]$EMAIL[/navy]
Code:
/usr/local/bin/mutt -s [green][i]"$SUBJECT"[/i][/green] -a [navy]$SPOOLFILE[/navy] [navy]$EMAIL[/navy] [teal]<[/teal] [navy]$SPOOLFILE[/navy]

Feherke.
 
Would it be something like this:
code
do_expired()
{
sqlplus -s mac/mac789 << ENDOFSQL
@${WORKDIR}/expirydate.sql
exit;
ENDOFSQL
SPOOLFILE=$WORKDIR/expirydate.csv
}
/code
?????
 
Hi

Personally I not suggested any correction because I do not understand your code. What happens with the file specified in $SPOOLFILE ? Because in what you posted nothing happens. Maybe in the SQL script files ? If yes, then what ?

Note that the correct TGML markup for code is [tt][ignore]
Code:
[/ignore][/tt] .. [tt][ignore]
[/ignore][/tt].

Feherke.
 
within my function..my SQL does create a spoolfile...
I want the menu option selected...to email the report selected.Which PHV suggested...
above code is my function..i wanted to know if i added the spoolfile in the correct place
 
my SQL does create a spoolfile
With which pathname ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top