cancel
Showing results for 
Search instead for 
Did you mean: 

HelpDesk Script

SOLVED
Go to solution
Charles Keyser
Frequent Advisor

HelpDesk Script

I have a helpdesk script (see Below). When I run the script as root ./Helpdesk it will bring up the screen I can select option 4 enter the users name and change the password

When I log in as HelpDesk enter their password it will bring up the screen I select option 4 and here is the message I receive. ANy ideas what I am missing? Thanks

Username to modify amb0503
/usr/bin/Helpdesk[92]: sudo: not found.



# Script is for the Help Desk to perform tasks for the sysadmin. These are limited and restricted to the Help Desk only.
# Any additional problems or issues, the Help Desk will contact the Sysadms to resolve them.
#
#
###############################################################
#!/usr/bin/sh
#
#
#
set -u
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)
===================================================
*************************
* ATI ALLVAC Help Desk *
*************************


1. Display printer status / print jobs.
a. Enter lpstat -p to view all printers
b. Enter lpstat -o to view all print request

2. Cancel a print job.

3. Cancel ALL print jobs for a printer.

4. Unlockes and Resets User Passwords
NOTE: A number or a group of letters will show on the screen,
write down and provide this information to the user.

5. This will execute the TOP command to look at the high load average on the servers. Monitoring purposes
NOTE: Control C breaks the process and returns to the Main Menu

6. EXIT this program.


===================================================

Select an Option # from above: "

read answer
case "$answer" in
6*|Qq|bye|Ee ) print "Quitting! See You Later, $(whoami)" ; exit ;;
5) if cont
then
/usr/bin/top
fi;;
1) if (( $? == 0 ))
then
print -n "Enter Printer Name: "
read prtr
lpstat $prtr
print -n "OK to clear screen [Hit Any Key]"
read h
fi;;
2) if (( $? == 0 ))
then
print -n "Enter Printer Name-job#: "
read prtr
cancel $prtr
fi;;
4) echo "Username to modify \c"; read USER
TESTUSER=`awk -v USER=${USER} -F: '$1~USER { print $1 }' /etc/passwd`
if test "${USER}" != "${TESTUSER}"
then
echo "${USER} is invalid!"
echo "Press [ENTER] to continue. \c"
read NOTHING
else
#This command looks at the account if it has a password liftime expired it will reset the account and enable it
sudo /usr/lbin/modprpw -x ${USER}
sleep 10
#This command runs the password reset brings up a prompt and 3 choices, selcting 3 is the best for the help desk
#passwd ${USER}
fi;;
3) 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
18 REPLIES
Pete Randall
Outstanding Contributor
Solution

Re: HelpDesk Script

Apparently the script uses the sudo command, which is an add-on product not directly supplied by HP. It needs to be in the user's path or the full path name of the sudo command should be specified in the script.


Pete

Pete
Charles Keyser
Frequent Advisor

Re: HelpDesk Script

Pete

What would be t he easiest way to resolve this? Our new help desk will be using the script and when the log in I would like for them to be able to reset and redo their password. Any help is appreciated
Pete Randall
Outstanding Contributor

Re: HelpDesk Script

The easiest way would be to change the script. Check to see where sudo is installed (probably /usr/local/bin) by doing "whence sudo". That should find it if run by root. Then edit the script itself and change all occurences of "sudo" to "/usr/local/bin/sudo".

You could also fix their PATH environment variable but that gets a bit more involved.


Pete

Pete
Michael Steele_2
Honored Contributor

Re: HelpDesk Script

Hi

Regarding the easy way, well, this is a build team or install team or a production team issue. Sudo can be easily installed during first build. It can easily be installed over the network now. Refer to your O/S version and the intenet express bundle for 11.23 and 11.31.

11.23 link

https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPUXIEXP1123

Sounds like its a project that you'll have to get approval on. A good way to start the ball rolling would be to id the servers needing the install. Do you have access to all?
Support Fatherhood - Stop Family Law
Charles Keyser
Frequent Advisor

Re: HelpDesk Script

Would this be the correct way?
#This command looks at the account if it has a password liftime expired it will reset the account and enable it
#sudo /usr/lbin/modprpw -x ${USER}
/usr/local/bin/sudo

I am not an expert at writing scripts
Michael Steele_2
Honored Contributor

Re: HelpDesk Script

Oh. I didn't read this as a PATH environment variable update. Well, this is easier but still probably a project needing approvals as I doubt the PATH env var will be identical on every box. So you should build a script to append the PATH var.

export PATH=$PATH:/usr/local/bin/sudo

Test out the above to see if it's what you want.
Support Fatherhood - Stop Family Law
Charles Keyser
Frequent Advisor

Re: HelpDesk Script

I would not be able to do any upgrade, the servers are running applications that if an upgrade was done the applications would not work. I have asked in the past and it was shot down
Charles Keyser
Frequent Advisor

Re: HelpDesk Script

I am not sure where you are asking me to input the export Path?
Would it be in the HelpDesk log in or profile or in the script
If in the script where?
sorry again I am trying to understand this and learn with your assistance
Thanks
-Charlie
Pete Randall
Outstanding Contributor

Re: HelpDesk Script

Charles,

The reason I suggested changing the script rather than changing the path is because you first have to figure out how and where the path is being set. You could append a "export PATH=$PATH:/usr/local/bin" statement to the users login profile, but that's going to depend on which shell they are using and how they are logging in.

Edit the helpdesk script and change "sudo" to "/usr/local/bin/sudo".


Pete

Pete
Charles Keyser
Frequent Advisor

Re: HelpDesk Script

I commented this out
#sudo /usr/lbin/modprpw -x ${USER}

Added
/usr/local/bin/sudo /usr/lbin/modprpw -x ${USER}

And it worked just fine. Thanks for all of yor help
-Charlie
Pete Randall
Outstanding Contributor

Re: HelpDesk Script

As you become more experienced in Sysadmin work, one of the habits you should acquire is to always use full path names in your scripts and make sure all your environment variables are defined.

Whoever wrote this script (I'm assuming it wasn't you) should scold herself!


Pete

Pete
Rita C Workman
Honored Contributor

Re: HelpDesk Script

Once you have the correct path for where sudo is installed, put it in the line where sudo is used that you mentioned earlier (in your case 4 stmt...)

...and whoever edited my script needs to go back and fix it; cause he menu is off from commands. If you're gonna change it - do it right.

Kindest regards,
Rita
Charles Keyser
Frequent Advisor

Re: HelpDesk Script

Rita

Sorry, I am just trying to fix what is there. I did not mean to offend or make anyone angry. The script is awesome and will work for us to do what we need. My apologies

-Charlie
Rita C Workman
Honored Contributor

Re: HelpDesk Script

Offend....it didn't come out right....I am totally flattered!

Maybe one day I'll share the one I wrote to cleanup some logfiles on Itanium boxes, cause they took out SAM and that quickie logfiles cleanup utility.

Kindest regards,
Rita
Charles Keyser
Frequent Advisor

Re: HelpDesk Script

Thanks Rita. I appreciate that. The script keeps me from being woke up in the early AM where the Help Desk folks can log in run the script get the password and send the folks on their merry way.

Again Thank you
-Charlie
Rita C Workman
Honored Contributor

Re: HelpDesk Script

I didn't use sudo............


ha ha....

Rita
Rita C Workman
Honored Contributor

Re: HelpDesk Script

OK.............hope this helps you a little. It's still looking for the path for sudo you need to enter.

Regards,
Rita
-------------------------------------------

# Script is for the Help Desk to perform tasks for the sysadmin. These are limited and restricted to the Help Desk only.
# Any additional problems or issues, the Help Desk will contact the Sysadms to resolve them.
#
# Modified: 3/10/10 /rcw To cleanup over appearance of script and put lines in order
# To include full path statement on commands
#
###############################################################
#!/usr/bin/sh
#
#
#
set -u
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)
===================================================
*************************
* ATI ALLVAC Help Desk *
*************************


Display printer status / print jobs.
1a. To view status one select printer
1b. To view status on all printers

2. Cancel a print job.

3. Cancel ALL print jobs for a printer.

4. Unlockes and Resets User Passwords
NOTE: A number or a group of letters will show on the screen,
write down and provide this information to the user.

5. This will execute the TOP command to look at the high load average on the servers. Monitoring purposes
NOTE: Control C breaks the process and returns to the Main Menu

6. EXIT this program.


===================================================

Select an Option # from above: "

read answer
case "$answer" in
6*|Qq|bye|Ee ) print "Quitting! See You Later, $(whoami)" ; exit ;;
5) if cont
then
/usr/bin/top
fi;;
1a) if (( $? == 0 ))
then
print -n "Enter Printer Name: "
read prtr
/usr/bin/lpstat $prtr
print -n "OK to clear screen [Hit Any Key]"
read h
fi;;
1b) if (( $? == 0 ))
then
print -n "Status of All Printers"
sleep 2
/usr/bin/lpstat -a
print -n "OK to clear screen [Hit Any Key]"
read h
fi;;

2) if (( $? == 0 ))
then
print -n "Enter Printer Name-job#: "
read prtr
/usr/bin/cancel $prtr
fi;;
3) 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
/usr/bin/lpstat $prtr_name | grep $prtr_name | sort -k1 | cut -d " " -f1 > $prtr_name.out
for rem_prt in `cat $prtr_name.out`
do
/usr/bin/cancel $rem_prt
done
else
echo "No Such Printer"
fi
fi;;
4) echo "Username to modify \c"; read USER
TESTUSER=`awk -v USER=${USER} -F: '$1~USER { print $1 }' /etc/passwd`
if test "${USER}" != "${TESTUSER}"
then
echo "${USER} is invalid!"
echo "Press [ENTER] to continue. \c"
read NOTHING
else
#This command looks at the account if it has a password liftime expired it will reset the account and enable it
sudo /usr/lbin/modprpw -x ${USER}
sleep 10
#This command runs the password reset brings up a prompt and 3 choices, selcting 3 is the best for the help desk
#passwd ${USER}
fi;;
5) if cont
then
/usr/bin/top
fi;;
esac
done
Rita C Workman
Honored Contributor

Re: HelpDesk Script

no guarantees....I did it quick & didn't test it.

no points please..