Results 1 to 10 of 10
Hi all
How to write script file to choice and run command?
I mean Display Menu
1. nslookup
2. ping
3. reboot
4. poweroff
0.exit
I want to logout current ...
- 12-16-2008 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 15
script menu file
Hi all
How to write script file to choice and run command?
I mean Display Menu
1. nslookup
2. ping
3. reboot
4. poweroff
0.exit
I want to logout current user when press 0.
Best Regards
Please
- 12-17-2008 #2Just Joined!
- Join Date
- Oct 2008
- Posts
- 48
For example:
echo "1) Option 1"
echo "2) Option 2"
echo "3) Option 3"
echo ""
read ACCION
case $ACCION in
1)
echo "option 1 selected!"
;;
2)
echo "option 2 selected!"
;;
3)
echo "option 3 selected!"
;;
- 12-18-2008 #3Just Joined!
- Join Date
- Dec 2008
- Posts
- 15
Hi thanks for your configuration
How can I deny ctrl key for that script?
that script was exit when press ctrl-c or ctrl z.
I want to protect from this key.
Please help me again
- 12-18-2008 #4
hi,
for building menus you can use "select"
then look for select (select is a bash built-in)Code:man bash
for controlling signals you can use "trap"
NOTE - there are some signals you can not trapCode:man trap
Linux and me it's a love story
- 12-18-2008 #5Just Joined!
- Join Date
- Dec 2008
- Posts
- 15
HI Thanks for your advice but I did not get ideal.
If you can ,please help me
- 12-18-2008 #6
hi,
this is how you can use trapLinux and me it's a love story
- 12-18-2008 #7Just Joined!
- Join Date
- Dec 2008
- Posts
- 15
Hi
Thanks for your reply
Is it?
if [ ! -e $lockfile ]; then
trap "rm -f $lockfile; exit" INT TERM EXIT
touch $lockfile
critical-section
rm $lockfile
trap - INT TERM EXIT
else
echo "critical-section is already running"
fi
If OK pls guide to me how to add this code in My script because of now I need urgent
that is why
I am hoping for your help
- 12-18-2008 #8We haven't seen your script yet.pls guide to me how to add this code in My script
Surely you didn't expect us to write the script for you? That won't help in the long run. You need to scroogle the following search terms:
Code:bash tutorial
We're not impolite, just busy writing our own scripts. :) When you have a script, and it doesn't work, and you have a specific question about why it doesn't work, we'd be glad to help.I need urgent--
Bill
Old age and treachery will overcome youth and skill.
- 12-19-2008 #9Just Joined!
- Join Date
- Dec 2008
- Posts
- 15
Hi
Following is my script
Please Edit
#!/bin/bash
# A menu driven Shell script which has following options
# Contents of /etc/passwd
# List of users currently logged
# Prsent handling directory
# Exit
# As per option do the job
# -----------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit Bash Shell Scripting Directory For Linux / UNIX for more information.
# -------------------------------------------------------------------------
while :
do
clear
echo " M A I N - M E N U"
echo "1. nslookup"
echo "2. bwm-ng"
echo "3. Reboot"
echo "4. PowerrOff"
echo "0. Exit"
echo -n "Please enter option [0 - 4]"
read opt
case $opt in
1) echo "************ nslookup *************";
nslookup;;
2) echo "*********** bwm-ng ";
bwm-ng;;
3) echo "Press [enter] for reboot";
reboot;;
4) echo "Press [enter] for Shut Down";
poweroff;;
0) echo "EXIT";
logout;;
*) echo "$opt is an invaild option. Please select option between 1-4 only";
echo "Press [enter] key to continue. . .";
read enterKey;;
esac
done
Thanks
- 12-19-2008 #10
It looks like you've done everything except actually fill in the individual items.
The next step is to do these things at the command line:
Then do the "trap dance", as previously suggested, and you're there.Code:man nslookup man ping man 8 shutdown
--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote