- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script input
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
Discussions
Discussions
Forums
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
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
тАО08-07-2008 06:40 AM
тАО08-07-2008 06:40 AM
#!/usr/bin/sh
#
#
#
trap '' INT
function cont
{
print -n "Do You Wish to Continue Y/N : "
read answ
if [[ $answ = [Yy] ]]
then
return 0
else
return 1
fi
}
while true
do
clear
print -n "
* HELP DESK MENU *
$(uname -n)
HELLO: $(whoami)
===================================================
1. Run Restricted SAM to reset passwords.
2. Display printer status / print jobs.
a. Enter lpstat -p to view all printers
b. Enter lpstat -o to view all print request
3. Cancel a print job.
4. Cancel ALL print jobs for a printer.
5. EXIT this program and RETURN TO COMMAND LINE.
6. Reset users passwords
7. Enable users account
===================================================
Select an Option # from above: "
read answer
case "$answer" in
5*|Qq|bye|Ee ) print "Quitting! See You Later, $(whoami)" ; exit ;;
1) if cont
then
. /usr/sbin/sam
fi;;
2) if (( $? == 0 ))
then
print -n "Enter Printer Name: "
read prtr
lpstat $prtr
print -n "OK to clear screen [Hit Any Key]"
read h
fi;;
3) if (( $? == 0 ))
then
print -n "Enter Printer Name-job#: "
read prtr
cancel $prtr
fi;;
4) if (( $? == 0 ))
then
print -n "..Enter printer name :"
read prtr_name
print -n "You enter printer ${prtr_name}"
print -n " Is this correct Y/N "
read answ
if [[ "$answ" = [Yy] ]]
then
lpstat $prtr_name | grep $prtr_name | sort -k1 | cut -d " " -f1 > $prtr_name.out
for rem_prt in `cat $prtr_name.out`
do
cancel $rem_prt
done
else
echo "No Such Printer"
fi
fi;;
esac
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 06:53 AM
тАО08-07-2008 06:53 AM
SolutionSo your question is?
A search might point you to this thread:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1218120768120+28353475&threadId=1029835
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 06:59 AM
тАО08-07-2008 06:59 AM
Re: Script input
When the select 6 I would like for a question to come up and ask "enter user ID"
once that happens it should generate an for a system generated password. Once completed the help desk will have the number, call the user and provide them the information. The user then should be able to log on enter this and change their password. The other number 7 is pretty much the same enables and resets their password
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 07:00 AM
тАО08-07-2008 07:00 AM
Re: Script input
while true
do
......your script
x|X) exit;;
done
Also, on every case....esac menu, I usually add an * to the end. So that if the user pressess anything except a valid key, s/he will get an error message.
while true
do
case $CHOICE in
1) (do something);;
2) (do something);;
x|X) exit;;
*) echo "Invalid selection! Press [ENTER] to continue! \c"; echo "\007";read NOTHING;;
esac
done
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 07:14 AM
тАО08-07-2008 07:14 AM
Re: Script input
I guess I am a little confused. Maybe a lot today then others.
while true
do
Is added at the beginning of my script?
SO if I add a line for number 6
6) if cont
then print -n "Enter users ID"
THIS is where I get hung up I have tried
usr/lbin/modprpw -x $myUserAcctName
/usr/lbin/modprpw -l -k -m
rstrpw=YES,exptm=45,nullpw=NO $myUserAcctName
It just does not seem to work. Am I adding this incorrectly? I wil be running this script on 3 servers 2 are 10.20's the other is 11.00
It has been awhile since I have written scripts. A long while. Any advice or input is greatly appreciated.
Thank you again for your time and patience
-Charlie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 07:26 AM
тАО08-07-2008 07:26 AM
Re: Script input
> once that happens it should generate an for a system generated password. Once completed the help desk will have the number, call the user and provide them the information. The user then should be able to log on enter this and change their password. The other number 7 is pretty much the same enables and resets their password
OK, if you want a random, clear-text password, use the Perl script I wrote here:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1231878
If you want an encrypted, random password use my variation here:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1252591
I also agree with Chris: for menu-based scripts, a 'while true do;' loop with an 'continue', 'break' and 'exit' controls works very well.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 07:27 AM
тАО08-07-2008 07:27 AM
Re: Script input
>I guess I am a little confused. Maybe a lot today then others.
I spend a lot of my life confused. You're not alone!
>while true
>do
>Is added at the beginning of my script?
Yes. The final 'done' is at the end of the script.
>SO if I add a line for number 6
>6) if cont
>then print -n "Enter users ID"
>THIS is where I get hung up I have tried
>usr/lbin/modprpw -x $myUserAcctName
>/usr/lbin/modprpw -l -k -m
>strpw=YES,exptm=45,nullpw=NO >$myUserAcctName
>It just does not seem to work. Am I adding this incorrectly? I wil be running this script on 3 servers 2 are 10.20's the other is 11.00
>It has been awhile since I have written scripts. A long while. Any advice or input is greatly appreciated.
Inside your case...esac statement you have already done most of your if/then logic. I would structure item 6 like this:
6) echo "Username to modify \c"; read USER
TESTNAME=`grep $USER /etc/passwd|awk -F: '{ print $1 }'`
if test "$USER" != "$TESTUSER"
then
echo "$USER is invalid!"
else
passwd $USER
fi;;
This snippet takes input from the operator, and compares it against the password database. It runs the password command if it matches, and echos an error code if it doesn't.
Because it is in a 'while true ' loop, the menu will display again and it can be chosen again.
>Thank you again for your time and patience
The best way to say 'thanks' is to assign points!
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 08:36 AM
тАО08-07-2008 08:36 AM
Re: Script input
6. Reset User Passwords
I receive a prompt
Username to modify
I eneter a user ada0160 who's account is locked
and I even enter mine cjk1402 to change my password it loops back to the main screen not allow any changes. I do see invalid user flash really quick
Again Thank you for your input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 10:03 AM
тАО08-07-2008 10:03 AM
Re: Script input
6) echo "Username to modify \c"; read USER
TESTNAME=`grep $USER /etc/passwd|awk -F: '{ print $1 }'`
if test "$USER" != "$TESTUSER"
then
echo "$USER is invalid!"
echo "Press [ENTER] to continue. \c"
read NOTHING
else
passwd $USER
fi;;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2008 10:03 AM
тАО08-07-2008 10:03 AM
Re: Script input
I finally realized that I did not select the drop menu for the points. I have set your reply s to 10. You have been very helpful.
-Charlie