#Hi:
# My observations:
# 1) always use a shell invocation: ksh, sh, bash, etc
# 2) place double quotes are the strings you display
# 3) always have at least one space around [ and ] in your if statements. (If
# you are using korn shell, your instructor will probably discuss using [[ and
# ]] in if statements
# 4) I'm assuming you want to loop at least once and terminate if the user
# picks 4
#
# Regards,
# ed
#!/bin/ksh
until [ "$cpick" -eq 4 ]
do
echo "Welcome to the super script program!"
echo "This program will create 2 files of your choice, please enter the first choice:"
read choice1
echo "great! please enter your second file name:"
read choice2
echo "Thank you please press enter to create the files"
read enter
touch $choice1
touch $choice2
chmod 700 $choice1 $choice2
echo "The files have now been created."
echo "The file $choice1 will now be reporting how many sessions are running in phobos."
echo "It will also report the names of those logged in and your user name."
echo "to continue please press enter"
read enter
echo "Now, we will display the information in $choice1 for you."
echo "Pick 1 is you want to see the number of login sessions"
echo "Pick 2 if you wish to see the usernames of the people on phobos"
echo "Pick 3 if you wish to see your user name"
echo "Pick 4 when you wish to continue to the $choice2 file"
echo "Note! whatever choices you pick will write data to the $choice1 file!"
read cpick
if [ "$cpick" -eq 1 ]
then
echo "This is how many login sessions are currently active" >> $choice1
who| wc -l >> $choice1
who| wc -l
elif [ "$cpick" -eq 2 ]
then
echo "This is who is logged in on phobos " >> $choice1
who|cut -c1-11 >> $choice1
who|cut -c1-11
elif [ "$cpick" -eq 3 ]
then
echo "This is your user name" >> $choice1
whoami >> $choice1
whoami
fi
done