Results 1 to 2 of 2
Hello all,
I very rarely use message boards, but I recently enrolled in a Unix/Linux class and we have to write our own script files. I cannot figure out how ...
- 12-10-2006 #1Just Joined!
- Join Date
- Dec 2006
- Posts
- 1
Linux Script Help
Hello all,
I very rarely use message boards, but I recently enrolled in a Unix/Linux class and we have to write our own script files. I cannot figure out how to insert a "while" loop in my current script file. I want the loop to revert back to the selection menu after the user makes a selection (ie. They choose #1, the date displays, and then it takes them back to the menu 1-6) Also, what would be a good use of a "here" document and "if" statement within this script file. I am very new to all this and ANY help would be much appreciated. I have read over many script help forums/web pages/text books...but nothing seems to make it clear enough for me to understand how to implement it into an actual script file. I know this script may seem pretty basic, but that's all it has to be, nothing complex. This is the basic layout of the script I am creating, but if you have any other suggestions or neat tricks, I'll give it a try. I am on a tight schedule, with this being due Tuesday 12/12. Thanks in advance...
#!/bin/ksh
cat <<tab
Please enter your selection:
1)Date
2)Users
3)View Files
4)View Directories
5)Current Processes
6)Exit
tab
read ans
echo "You have selected: $ans"
echo "Press enter to continue"
read hold
case $ans in
1)echo "Today's date is:"
echo
date
;;
2)echo "These users are currently logged on:"
echo
who | sort -r | awk '{print $1}'
;;
3)echo "These are my files:"
echo
ls -F | grep -v / | column
;;
4)echo "These are my directories:"
echo
ls -F | grep / | column
;;
5)echo "These are my current processes:"
echo
ps
;;
6)exit 0
esac
sleep 5
clear
- 12-10-2006 #2forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,096
Sorry, but it's against the forum rules to post homework questions:
http://www.linuxforums.org/forum/lin...ums-rules.htmloz
→ new members/users: read this first | new member faq
→ no private messages requesting computer support - post them on the forums!
→ please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.


