1752795 Members
6152 Online
108789 Solutions
New Discussion юеВ

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 18
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