Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm new to unix and I'm writing a bash script that will prompt 5 command menu. I got stuck on the last two command that ask for the emalier with a subject & an attachment and the menu that's surrounded by a loop so that when one option is concluded it will go back to the menu until the user selects an option x to exit. Any help would be appreciated. Here is an example of the program I wrote so far but got stuck on number 4 and 5:
#!/bin/bash
echo -e "\n COMMAND MENU\n"
echo " 1. Current date and time"
echo " 2. Users currently logged in"
echo " 3. Name of the working directory"
echo " 4. Email someone with a subject and an attachment"
echo -e " 5. Press X to exit\n"
echo -e "Enter 1-5: \c"
read answer
echo
case "$answer" in
1.)
date
;;
2.)
who
;;3.)
pwd
;;
4.)
5.)
*)
echo "There is no selection: $answer"
;;esac
-----------------------
Thanks

#!/bin/ksh
# set -x
localmail() {
echo "What is the mail recipient?"
read mailto
echo "What full path to the file would you like to attach?"
read fullpath
attachment=`echo $fullpath | awk -F "/" '{ print $NF }'`
echo "What is the subject of the mail message?"
read subject
echo $mailto $fullpath $subject $attachment
(uuencode $fullpath $attachment; echo "text") | mail -s "$subject" $mailto
}
echo ""
echo "COMMAND MENU"
PS3='Your choice? '
select ans in \
"Current date and time" \
"Users currently logged in" \
"Name of the working directory" \
"Email someone with a subject and an attachment" \
"Exit"
do
case $REPLY in
1 ) date ;;
2 ) who ;;
3 ) pwd ;;
4 ) localmail ;;
5 ) exit 0 ;;
* ) echo "Sorry, no default selection" ;;
esac
done

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |