A simple menu to call a SQL and email output to a user:
here is what i have:
#!/bin/ksh
WORKDIR=/u1/home/ops
SPOOLFILE=/u1/home/ops/menopt15.lst
LOGO="Users Takeon/Expired"
LIST="xxx@help.co.za xxxb@help.co.za xxxc@help.co.za graham.goliath@gmail.com"
#Option1=" Run User Takeon Report" ;
#Option2=" Run User Expired Report" ;
#Option3=" Exit Program" ;
Displaymenu () {
clear
echo `DATE`
echo
echo "\t\t\t\t" $LOGO
echo
echo "\t\Select 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 Prgram "
echo -n "Enter option then ENTER to continue:;"
}
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
if [ "$LIST" = xxxa@help.co.za ]
then
do_email ()
PressEnter
fi
}
report_Expired()
{
echo "Executing Run Expired Report"
do_expired()
echo " Enter email address then enter to continue: \c"
read email
if [ "$LIST" = xxxa@help.co.za ]
then
do_email ()
PressEnter
fi
}
#Function Exit()
#{
# echo "Exit Program"
# pressEnter
# ... perform certain actions
#}
do_takeon()
{
sqlplus -s mac/mac789@${WORKDIR}/takeondate.sql
}
do_expired()
{
sqlplus -s mac/mac789@${WORKDIR}/expirydate.sql
}
do_email()
{
echo "Emailing report now"
SUBJECT="User Takeon report"
TO=xxxa@help.co.za
(
cat $SPOOLFILE
) | /usr/local/bin/mutt -s "$SUBJECT" -a $SPOOLFILE $TO
}
while true
do
displaymenu
read answer
case $answer in
1) Run User Takeon Report ;;
2) Run User Expired Report ;;
3) break ;;
esac
done
clear
do_takeon()
{
sqlplus -s mac/mac789@${WORKDIR}/takeondate.sql
}
do_expired()
{
sqlplus -s mac/mac789@${WORKDIR}/expirydate.sql
}
is this correct? something looks amiss
here is what i have:
#!/bin/ksh
WORKDIR=/u1/home/ops
SPOOLFILE=/u1/home/ops/menopt15.lst
LOGO="Users Takeon/Expired"
LIST="xxx@help.co.za xxxb@help.co.za xxxc@help.co.za graham.goliath@gmail.com"
#Option1=" Run User Takeon Report" ;
#Option2=" Run User Expired Report" ;
#Option3=" Exit Program" ;
Displaymenu () {
clear
echo `DATE`
echo
echo "\t\t\t\t" $LOGO
echo
echo "\t\Select 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 Prgram "
echo -n "Enter option then ENTER to continue:;"
}
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
if [ "$LIST" = xxxa@help.co.za ]
then
do_email ()
PressEnter
fi
}
report_Expired()
{
echo "Executing Run Expired Report"
do_expired()
echo " Enter email address then enter to continue: \c"
read email
if [ "$LIST" = xxxa@help.co.za ]
then
do_email ()
PressEnter
fi
}
#Function Exit()
#{
# echo "Exit Program"
# pressEnter
# ... perform certain actions
#}
do_takeon()
{
sqlplus -s mac/mac789@${WORKDIR}/takeondate.sql
}
do_expired()
{
sqlplus -s mac/mac789@${WORKDIR}/expirydate.sql
}
do_email()
{
echo "Emailing report now"
SUBJECT="User Takeon report"
TO=xxxa@help.co.za
(
cat $SPOOLFILE
) | /usr/local/bin/mutt -s "$SUBJECT" -a $SPOOLFILE $TO
}
while true
do
displaymenu
read answer
case $answer in
1) Run User Takeon Report ;;
2) Run User Expired Report ;;
3) break ;;
esac
done
clear
do_takeon()
{
sqlplus -s mac/mac789@${WORKDIR}/takeondate.sql
}
do_expired()
{
sqlplus -s mac/mac789@${WORKDIR}/expirydate.sql
}
is this correct? something looks amiss