- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: scripts query
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 07:06 PM
01-12-2005 07:06 PM
scripts query
i test a script to let say enter x option to exit the from the shell,
for e.g
case $i in
x|X) exit ;;
but when i choose x or X , i want it to logout from the operation menu but it only go out to the shell prompt.. what modification is needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 07:18 PM
01-12-2005 07:18 PM
Re: scripts query
You need this
case $i in
x|X) exit ;;
esac
IA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 07:21 PM
01-12-2005 07:21 PM
Re: scripts query
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 07:40 PM
01-12-2005 07:40 PM
Re: scripts query
if i understand it right, you want to exit from shell if option 'x' is choose?
Then you have to insert this script as shell for the user in /etc/passwd instead of a OS-shell.
regards
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 07:42 PM
01-12-2005 07:42 PM
Re: scripts query
if it is a menu script then use
"exec menu.ksh" instead of "ksh menu.ksh".
By doing this the current shell is replaced by the script, so exiting the script will force a logout.
Try using "logout" instead of "exit".
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 07:45 PM
01-12-2005 07:45 PM
Re: scripts query
1) System_menu ;;
x|X) break ;;
*) eczho
echo Invalid choice.
echo Try again.
sleep 1
echo ;;
esac
done
Read this doc for more detail (Shell User's Guide)
www.docs.hp.com/en/B2355-90046
Regard
tienna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 07:52 PM
01-12-2005 07:52 PM
Re: scripts query
select.
Put your case structure in a dummy while/until loop.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 08:22 PM
01-12-2005 08:22 PM
Re: scripts query
#! /usr/bin/sh
while : ; do
clear
read OPT
case $OPT in
[x,X])
exit 0
;;
esac
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 08:37 PM
01-12-2005 08:37 PM
Re: scripts query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 08:45 PM
01-12-2005 08:45 PM
Re: scripts query
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 08:51 PM
01-12-2005 08:51 PM
Re: scripts query
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 08:56 PM
01-12-2005 08:56 PM
Re: scripts query
kill -9 pid
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 09:49 PM
01-12-2005 09:49 PM
Re: scripts query
as i said before and agreeing with Fred:
Set your script in /etc/passwd as a shell for the involved user.
instead
user1:*:217:200:full name,location,:/home/user1:/usr/bin/csh
to
user1:*:217:200:full name,location,:/home/user1:/home/user1/scriptname
Regards
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2005 09:50 PM
01-12-2005 09:50 PM
Re: scripts query
try "exec menu.sh"
instead of "sh menu.sh".
regards,
Thierry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2005 01:15 AM
01-13-2005 01:15 AM
Re: scripts query
Here's a menu I use:
# cat lp.mnu
#!/bin/sh
# lp.mnu
# A menu to assist in supporting the lp spooler
# Geoff Wild
# March 20 2002
# Main logic starts at MAIN LOGIC
# The logo will be displayed at the top of the screen6.
LOGO="GEUNIX LP Support Menu"
#------------------------------------------------------
# MENU PROMPTS
#------------------------------------------------------
# A list of menu prompts to be displayed for the user.
# The list can be modified.
# In this first list, enter the menu prompt as it should appear
# on the screen for each of the letters A - L. In this example
# menu pick variables emenu through lmenu are blank as there
# are no menu selections for keys E through L.
amenu="a. Check printer status" ;
bmenu="b. Add Printer" ;
cmenu="c. Delete Printer" ;
dmenu="d. Disable a Print Queue" ;
emenu="e. Enable a Print Queue " ;
fmenu="f. Backup the Spooler Configuration" ;
gmenu="g. Restore the Spooler Configuration" ;
hmenu="h. Check the Print Spooler log " ;
imenu="i. Check the iprprtpkg log " ;
jmenu="j. Check the iprprtpkg status " ;
kmenu=" " ;
lmenu=" " ;
#------------------------------------------------------
# MENU FUNCTION DEFINITIONS
#------------------------------------------------------
# Define a function for invalid menu picks
# The function loads an error message into a variable
badchoice () { MSG="Invalid Selection ... Please Try Again" ; }
# For each prompt displayed above, there is a list of
# commands to execute in response to the user picking the
# associated letter.
# They are defined as functions
# apick () through lpick () where
# apick () corresponds to the menu
# prompt amenu which is selected
# selected by pressing a or A.
# bpick () corresponds to the menu
# prompt bmenu which is selected by
# pressing b or B and so on.
# Any menu item that is not
# assigned a set of commands, is
# assigned
# the function badchoice () as a default for that pick.
# If the user
# selects a menu key that is assigned
# to badchoice (). This function
# causes an error message to be
# displayed on the screen.
# To add items to this second
# list, replace badchoice ()
# with the commands to run when
# that letter is pressed.
# The following steps simply define
# the functions, but do not cause
# any shell program steps to be executed.
apick () { echo enter queue to check ; read Q ; /opt/hpnpl/bin/lpst $Q | more ; }
bpick () { /usr/local/bin/lp.queue.mnu ; }
cpick () { echo coming soon ; sleep 5;}
dpick () { echo Enter queue name ; read Q ; /usr/bin/disable $Q ; sleep 5; }
epick () { echo Enter queue name ; read Q ; /usr/bin/enable $Q ; sleep 5 ; }
fpick () { echo Backing up the spooler configuration to /var/sam/lp/lp.new....please wait...; /usr/sam/lbin/lpmgr -S -v -xsavedir=/var/sam/lp/ ; cp -r -p /var/sam/lp/lp.new/* /var/sam/lp/ ; echo Press Enter To Return to Menu... ;read DUMMY ; }
gpick () { echo LAST CHANCE - you have 5 seconds to abort - ctrl c to abort ; sleep 5 ; echo Restoring the spooler configuration....please wait...; /usr/sam/lbin/lpmgr -R -xsavedir=/var/sam/lp/ ; echo Press Enter To Return to Menu... ;read DUMMY ; }
hpick () { tail -200 /var/spool/lp/log |more ; echo Press Enter To Return to Menu... ; read DUMMY ;}
ipick () { tail -200 /etc/cmcluster/IPRPRT/iprprt.cntl.log |more ;echo Press Enter To Return to Menu... ; read DUMMY ; }
jpick () { cmviewcl ;echo Press Enter To Return to Menu... ; read DUMMY; }
kpick () { badchoice ; }
lpick () { badchoice ; }
#------------------------------------------------------
# DISPLAY FUNCTION DEFINITION
#------------------------------------------------------
# This function displays the menu.
# The routine clears the screen, echoes
# the logo and menu prompts
# and some additional messages.
# Note that this definition does
# not cause the function to
# be executed yet, it just defines
# it ready to be executed
themenu () {
# clear the screen
clear
echo `date`
echo
echo "\t\t\t" $LOGO
echo
echo "\t\tPlease Select:"
echo
echo "\t\t\t" $amenu
echo "\t\t\t" $bmenu
echo "\t\t\t" $cmenu
echo "\t\t\t" $dmenu
echo "\t\t\t" $emenu
echo "\t\t\t" $fmenu
echo "\t\t\t" $gmenu
echo "\t\t\t" $hmenu
echo "\t\t\t" $imenu
echo "\t\t\t" $jmenu
echo "\t\t\t" $kmenu
echo "\t\t\t" $lmenu
echo "\t\t\tx. Exit"
echo
echo $MSG
echo
echo Select by pressing the letter and then ENTER ;
}
#------------------------------------------------------
# MAIN LOGIC
#------------------------------------------------------
# Every thing up to this point has been to define
# variables or functions.
# The program actually starts running here.
# Clear out the error message variable
MSG=
# Repeat the menu over and over
# Steps are:
# 1. Display the menu
# 2. 'read' a line of input from the key board
# 3. Clear the error message
# 4. Check the answer for a or A or b or B etc. and dispatch
# to the appropriate program or function or exit
# 5. If the entry was invalid call the badchoice () function
# to initialize MSG to an error message
# 6. This error message is used when setting up the menu
# for a menu pick that is valid but has no command
# associated with it.
while true
do
# 1. display the menu
themenu
# 2. read a line of input from the keyboard
read answer
# 3. Clear any error message
MSG=
# 4. Execute one of the defined functions based on the
# letter entered by the user.156.
# 5. If the choice was E through L, the pre-defined
# function for that pick will execute badchoice ()
# which loads an error message into MSG
case $answer in
a|A) apick;;
b|B) bpick;;
c|C) cpick;;
d|D) dpick;;
e|E) epick;;
f|F) fpick;;
g|G) gpick;;
h|H) hpick;;
i|I) ipick;;
j|J) jpick;;
k|K) kpick;;
l|L) lpick;;
# If the user selects =91x=92 to exit then break out
# of this loop
x|X) break;;
# 6. If the entry was invalid call the badchoice function
# to initialize MSG to an error message
*) badchoice;;
esac
# Do it again until the user enters =91x=92.
done
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2005 06:54 PM
04-25-2005 06:54 PM