<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script input in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248077#M687465</link>
    <description>Chris&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;-Charlie</description>
    <pubDate>Thu, 07 Aug 2008 17:03:37 GMT</pubDate>
    <dc:creator>Charles Keyser</dc:creator>
    <dc:date>2008-08-07T17:03:37Z</dc:date>
    <item>
      <title>Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248068#M687456</link>
      <description>I have a script that was written in a previous thread. We are using the Help Desk to reset and enable accounts can some help me update this I seem to have a brain cramp. Here is the script. Any help would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt; #&lt;BR /&gt; #&lt;BR /&gt; #&lt;BR /&gt; trap '' INT&lt;BR /&gt; function cont&lt;BR /&gt; {&lt;BR /&gt; print -n "Do You Wish to Continue Y/N : "&lt;BR /&gt; read answ&lt;BR /&gt; if [[ $answ = [Yy] ]]&lt;BR /&gt; then&lt;BR /&gt; return 0&lt;BR /&gt; else&lt;BR /&gt; return 1&lt;BR /&gt; fi&lt;BR /&gt; }&lt;BR /&gt; while true&lt;BR /&gt; do&lt;BR /&gt; clear&lt;BR /&gt; print -n "&lt;BR /&gt; * HELP DESK MENU *&lt;BR /&gt; $(uname -n)&lt;BR /&gt; HELLO: $(whoami)&lt;BR /&gt; ===================================================&lt;BR /&gt; 1. Run Restricted SAM to reset passwords.&lt;BR /&gt;&lt;BR /&gt; 2. Display printer status  / print jobs.&lt;BR /&gt;    a. Enter lpstat -p to view all printers&lt;BR /&gt;    b. Enter lpstat -o to view all print request&lt;BR /&gt;&lt;BR /&gt; 3. Cancel a print job.&lt;BR /&gt;&lt;BR /&gt; 4. Cancel ALL print jobs for a printer.&lt;BR /&gt;&lt;BR /&gt; 5. EXIT this program and RETURN TO COMMAND LINE.&lt;BR /&gt;&lt;BR /&gt; 6. Reset users passwords &lt;BR /&gt; &lt;BR /&gt; 7. Enable users account&lt;BR /&gt;&lt;BR /&gt; ===================================================&lt;BR /&gt;&lt;BR /&gt; Select an Option # from above: "&lt;BR /&gt;&lt;BR /&gt; read answer&lt;BR /&gt; case "$answer" in&lt;BR /&gt; 5*|Qq|bye|Ee ) print "Quitting! See You Later, $(whoami)" ; exit ;;&lt;BR /&gt; 1) if cont&lt;BR /&gt; then&lt;BR /&gt;. /usr/sbin/sam&lt;BR /&gt; fi;;&lt;BR /&gt; 2) if (( $? == 0 ))&lt;BR /&gt; then&lt;BR /&gt; print -n "Enter Printer Name: "&lt;BR /&gt; read prtr&lt;BR /&gt; lpstat $prtr&lt;BR /&gt; print -n "OK to clear screen [Hit Any Key]"&lt;BR /&gt; read h&lt;BR /&gt; fi;;&lt;BR /&gt; 3) if (( $? == 0 ))&lt;BR /&gt; then&lt;BR /&gt; print -n "Enter Printer Name-job#: "&lt;BR /&gt; read prtr&lt;BR /&gt; cancel $prtr&lt;BR /&gt; fi;;&lt;BR /&gt; 4) if (( $? == 0 ))&lt;BR /&gt; then&lt;BR /&gt; print -n "..Enter printer name :"&lt;BR /&gt; read prtr_name&lt;BR /&gt; print -n "You enter printer ${prtr_name}"&lt;BR /&gt; print -n " Is this correct Y/N "&lt;BR /&gt; read answ&lt;BR /&gt; if [[ "$answ" = [Yy] ]]&lt;BR /&gt; then&lt;BR /&gt; lpstat $prtr_name | grep $prtr_name | sort -k1 | cut -d " " -f1 &amp;gt; $prtr_name.out&lt;BR /&gt; for rem_prt in `cat $prtr_name.out`&lt;BR /&gt; do&lt;BR /&gt; cancel $rem_prt&lt;BR /&gt; done&lt;BR /&gt; else&lt;BR /&gt; echo "No Such Printer"&lt;BR /&gt; fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; fi;;&lt;BR /&gt; esac&lt;BR /&gt; done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Aug 2008 13:40:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248068#M687456</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T13:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248069#M687457</link>
      <description>Hi Charles:&lt;BR /&gt;&lt;BR /&gt;So your question is?&lt;BR /&gt;&lt;BR /&gt;A search might point you to this thread:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1218120768120+28353475&amp;amp;threadId=1029835" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1218120768120+28353475&amp;amp;threadId=1029835&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 07 Aug 2008 13:53:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248069#M687457</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-07T13:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248070#M687458</link>
      <description>Sorry I really have a brain cramp. What I would like to do is have  6 an 7 executed by the help desk.&lt;BR /&gt;When the select 6 I would like for a question to come up and ask "enter user ID"&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;I hope this helps.</description>
      <pubDate>Thu, 07 Aug 2008 13:59:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248070#M687458</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T13:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248071#M687459</link>
      <description>Usually I structure these things differently.  I start by putting them in a 'while true' loop.  This means that no matter what the user does, the menu script always loops.  But include an exit option&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;......your script&lt;BR /&gt;&lt;BR /&gt;x|X) exit;;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;while true&lt;BR /&gt;do    &lt;BR /&gt;    case $CHOICE in &lt;BR /&gt;    1)      (do something);;&lt;BR /&gt;    2)      (do something);;&lt;BR /&gt;    x|X)    exit;;&lt;BR /&gt;    *) echo "Invalid selection! Press [ENTER] to continue! \c"; echo "\007";read NOTHING;;&lt;BR /&gt;   esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 07 Aug 2008 14:00:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248071#M687459</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2008-08-07T14:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248072#M687460</link>
      <description>Chris&lt;BR /&gt;&lt;BR /&gt;I guess I am a little confused. Maybe a lot today then others. &lt;BR /&gt;&lt;BR /&gt; while true&lt;BR /&gt;do  &lt;BR /&gt;&lt;BR /&gt;Is added at the beginning of my script?&lt;BR /&gt;&lt;BR /&gt;SO if I add a line for number 6&lt;BR /&gt;&lt;BR /&gt;6) if cont&lt;BR /&gt;then print -n "Enter users ID"&lt;BR /&gt;&lt;BR /&gt;THIS is where I get hung up I have tried &lt;BR /&gt;usr/lbin/modprpw -x $myUserAcctName&lt;BR /&gt;/usr/lbin/modprpw -l -k -m&lt;BR /&gt;rstrpw=YES,exptm=45,nullpw=NO $myUserAcctName&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;It has been awhile since I have written scripts. A long while. Any advice or input is greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thank you again for your time and patience&lt;BR /&gt;&lt;BR /&gt;-Charlie&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Aug 2008 14:14:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248072#M687460</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T14:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248073#M687461</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; 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&lt;BR /&gt;&lt;BR /&gt;OK, if you want a random, clear-text password, use the Perl script I wrote here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1231878" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1231878&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you want an encrypted, random password use my variation here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1252591" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1252591&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I also agree with Chris: for menu-based scripts, a 'while true do;' loop with an 'continue', 'break' and 'exit' controls works very well.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 07 Aug 2008 14:26:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248073#M687461</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-07T14:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248074#M687462</link>
      <description>&amp;gt;Chris&lt;BR /&gt;&amp;gt;I guess I am a little confused. Maybe a lot today then others. &lt;BR /&gt;&lt;BR /&gt;I spend a lot of my life confused.  You're not alone!&lt;BR /&gt;&lt;BR /&gt;&amp;gt;while true&lt;BR /&gt;&amp;gt;do &lt;BR /&gt;&lt;BR /&gt;&amp;gt;Is added at the beginning of my script?&lt;BR /&gt;&lt;BR /&gt;Yes.  The final 'done' is at the end of the script.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;SO if I add a line for number 6&lt;BR /&gt;&amp;gt;6) if cont&lt;BR /&gt;&amp;gt;then print -n "Enter users ID"&lt;BR /&gt;&lt;BR /&gt;&amp;gt;THIS is where I get hung up I have tried &lt;BR /&gt;&amp;gt;usr/lbin/modprpw -x $myUserAcctName&lt;BR /&gt;&amp;gt;/usr/lbin/modprpw -l -k -m&lt;BR /&gt;&amp;gt;strpw=YES,exptm=45,nullpw=NO &amp;gt;$myUserAcctName&lt;BR /&gt;&lt;BR /&gt;&amp;gt;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&lt;BR /&gt;&amp;gt;It has been awhile since I have written scripts. A long while. Any advice or input is greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Inside your case...esac statement you have already done most of your if/then logic. I would structure item 6 like this:&lt;BR /&gt;6) echo "Username to modify \c"; read USER&lt;BR /&gt;TESTNAME=`grep $USER /etc/passwd|awk -F: '{ print $1 }'`&lt;BR /&gt;if test "$USER" != "$TESTUSER"&lt;BR /&gt;then&lt;BR /&gt;echo "$USER is invalid!"&lt;BR /&gt;else&lt;BR /&gt;passwd $USER&lt;BR /&gt;fi;;&lt;BR /&gt;&lt;BR /&gt;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.  &lt;BR /&gt;&lt;BR /&gt;Because it is in a 'while true ' loop, the menu will display again and it can be chosen again.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Thank you again for your time and patience&lt;BR /&gt;&lt;BR /&gt;The best way to say 'thanks' is to assign points!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 07 Aug 2008 14:27:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248074#M687462</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2008-08-07T14:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248075#M687463</link>
      <description>Thanks again. I have added your logic to the script when I select the menu number &lt;BR /&gt;&lt;BR /&gt;6. Reset User Passwords&lt;BR /&gt;&lt;BR /&gt;I receive a prompt &lt;BR /&gt;&lt;BR /&gt;Username to modify&lt;BR /&gt;&lt;BR /&gt;I eneter a user ada0160 who's account is locked&lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;Again Thank you for your input.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Aug 2008 15:36:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248075#M687463</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T15:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248076#M687464</link>
      <description>&lt;!--!*#--&gt;Yes, I did leave something out of that previous snippet.  Here I will correct it:&lt;BR /&gt;&lt;BR /&gt;6) echo "Username to modify \c"; read USER&lt;BR /&gt;TESTNAME=`grep $USER /etc/passwd|awk -F: '{ print $1 }'`&lt;BR /&gt;if test "$USER" != "$TESTUSER"&lt;BR /&gt;then&lt;BR /&gt;      echo "$USER is invalid!"&lt;BR /&gt;      echo "Press [ENTER] to continue. \c"&lt;BR /&gt;      read NOTHING&lt;BR /&gt;else&lt;BR /&gt;      passwd $USER&lt;BR /&gt;fi;;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Aug 2008 17:03:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248076#M687464</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2008-08-07T17:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248077#M687465</link>
      <description>Chris&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;-Charlie</description>
      <pubDate>Thu, 07 Aug 2008 17:03:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248077#M687465</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T17:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248078#M687466</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;You can/should reward points to all respondents of your thread to the degree that you feel they helped you:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/helptips.do?#28" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/helptips.do?#28&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 07 Aug 2008 17:08:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248078#M687466</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-07T17:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248079#M687467</link>
      <description>JRH&lt;BR /&gt;&lt;BR /&gt;My apologies to you. I did add points to yours also and failed to acknowledge that&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;&lt;BR /&gt;Maybe I am missing something here or my skills are just lacking I made the changes as you sent&lt;BR /&gt;here is what I receive now&lt;BR /&gt;&lt;BR /&gt;select option for password reset&lt;BR /&gt;&lt;BR /&gt;Username to modify cjk1402&lt;BR /&gt;cjk1402 is invalid!&lt;BR /&gt;Press [ENTER] to continue&lt;BR /&gt;&lt;BR /&gt;Since I am a user why would I receive the the invalid user?&lt;BR /&gt;&lt;BR /&gt;I did a cat on /etc/passwd and my user id is there.&lt;BR /&gt;&lt;BR /&gt;-Charlie</description>
      <pubDate>Thu, 07 Aug 2008 17:18:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248079#M687467</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T17:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248080#M687468</link>
      <description>Instead of 'cat-ing' /etc/passwd, try grep'ing it with the following:&lt;BR /&gt;&lt;BR /&gt;grep $USER /etc/passwd|awk -F: '{ print $1 }'&lt;BR /&gt;&lt;BR /&gt;The grep command matches the input string $USER with any entry in /etc/passwd.  The awk portion of the command sets the colon (:) as the field delimiter and then prints the first field in the returned line.&lt;BR /&gt;&lt;BR /&gt;So the grep command might return something like:&lt;BR /&gt;&lt;BR /&gt;user1:WSzIkVWhiLvCM:1154:20::/users/user1:/bin/ksh&lt;BR /&gt;&lt;BR /&gt;The first field is the username.  Then comes the encrpyted password (unless you are using a trusted system) then the user number (UID), then the group ID (GID), then the home directory for user1, and the last field is the shell that user1 will use on login.  You are interested ONLY in the first field.&lt;BR /&gt;&lt;BR /&gt;So try this experiment......&lt;BR /&gt;First use grep to find your user ID.  It must be an exact match or it won't work.&lt;BR /&gt;Then try the grep command in combination with the awk command I printed above.  If the grep command worked, then the awk command should also.  &lt;BR /&gt;&lt;BR /&gt;It is possible to do the entire line with a single awk command, but I use grep as a matter of habit.&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 07 Aug 2008 17:35:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248080#M687468</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2008-08-07T17:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248081#M687469</link>
      <description>Hi (again) Charlie:&lt;BR /&gt;&lt;BR /&gt;Chris's code mixes variable names -- TESTUSER and TESTNAME -- and they are not the same!&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -u&lt;BR /&gt;echo "Username to modify \c"; read USER&lt;BR /&gt;TESTUSER=`awk -v USER=${USER} -F: '$1~USER { print $1 }' /etc/passwd`&lt;BR /&gt;if test "$USER" != "$TESTUSER"&lt;BR /&gt;then&lt;BR /&gt;      echo "$USER is invalid!"&lt;BR /&gt;      echo "Press [ENTER] to continue. \c"&lt;BR /&gt;      read NOTHING&lt;BR /&gt;else&lt;BR /&gt;      echo   $USER&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Note that I added 'set -u' to the script to catch undefined (empty) variables.  This makes debugging so much easier!&lt;BR /&gt;&lt;BR /&gt;Note too that I removed a 'grep'/'awk' pipeline.  Awk pattern matches and the 'grep' process is wasteful.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 07 Aug 2008 17:44:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248081#M687469</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-07T17:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248082#M687470</link>
      <description>JRF&lt;BR /&gt;&lt;BR /&gt;here is the complete script with changes. I ran it and it still says, maybe I have typed something incorrectly?  -Charlie&lt;BR /&gt;&lt;BR /&gt;Select an Option # from above: 5&lt;BR /&gt;Username to modify cjk1402&lt;BR /&gt;cjk1402 is invalid!&lt;BR /&gt;Press [ENTER] to continue. &lt;BR /&gt;&lt;BR /&gt;Here is what I have done from the command line to verify if I am in the passwd file&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;grep cjk1402 /etc/passwd|awk -F: '{ print $1 }' &lt;BR /&gt;&lt;BR /&gt;here is the return&lt;BR /&gt;&lt;BR /&gt;cjk1402&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;++++++++++++++++++++++++++++++++++++++++++++&lt;BR /&gt;&lt;BR /&gt;trap '' INT&lt;BR /&gt; function cont&lt;BR /&gt; {&lt;BR /&gt; print -n "Do You Wish to Continue Y/N : "&lt;BR /&gt; read answ&lt;BR /&gt; if [[ $answ = [Yy] ]]&lt;BR /&gt; then&lt;BR /&gt; return 0&lt;BR /&gt; else&lt;BR /&gt; return 1&lt;BR /&gt; fi&lt;BR /&gt; }&lt;BR /&gt; while true&lt;BR /&gt; do&lt;BR /&gt; clear&lt;BR /&gt; print -n "&lt;BR /&gt; * HELP DESK MENU *&lt;BR /&gt; $(uname -n)&lt;BR /&gt; HELLO: $(whoami)&lt;BR /&gt; ===================================================&lt;BR /&gt; 1. Run Restricted SAM to reset passwords.&lt;BR /&gt;&lt;BR /&gt; 2. Display printer status  / print jobs.&lt;BR /&gt;    a. Enter lpstat -p to view all printers&lt;BR /&gt;    b. Enter lpstat -o to view all print request&lt;BR /&gt;&lt;BR /&gt; 3. Cancel a print job.&lt;BR /&gt;&lt;BR /&gt; 4. Cancel ALL print jobs for a printer.&lt;BR /&gt;&lt;BR /&gt; 5. Reset User Passwords&lt;BR /&gt;&lt;BR /&gt; 6. EXIT this program and RETURN TO COMMAND LINE.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; ===================================================&lt;BR /&gt;&lt;BR /&gt; Select an Option # from above: "&lt;BR /&gt;&lt;BR /&gt; read answer&lt;BR /&gt; case "$answer" in&lt;BR /&gt; 6*|Qq|bye|Ee ) print "Quitting! See You Later, $(whoami)" ; exit ;;&lt;BR /&gt; 1) if cont&lt;BR /&gt; then&lt;BR /&gt;. /usr/sbin/sam&lt;BR /&gt; fi;;&lt;BR /&gt; 2) if (( $? == 0 ))&lt;BR /&gt; then&lt;BR /&gt; print -n "Enter Printer Name: "&lt;BR /&gt; read prtr&lt;BR /&gt; lpstat $prtr&lt;BR /&gt; print -n "OK to clear screen [Hit Any Key]"&lt;BR /&gt; read h&lt;BR /&gt; fi;;&lt;BR /&gt; 3) if (( $? == 0 ))&lt;BR /&gt; then&lt;BR /&gt; print -n "Enter Printer Name-job#: "&lt;BR /&gt; read prtr&lt;BR /&gt; cancel $prtr&lt;BR /&gt; fi;;&lt;BR /&gt; 5) echo "Username to modify \c"; read USER&lt;BR /&gt; TESTNAME=`awk -v USER=${USER} -F: '$1~USER { print $1 }' /etc/passwd`&lt;BR /&gt; if test "$USER" != "$TESTUSER"&lt;BR /&gt; then&lt;BR /&gt; echo "$USER is invalid!"&lt;BR /&gt; echo "Press [ENTER] to continue. \c"&lt;BR /&gt; read NOTHING&lt;BR /&gt; else&lt;BR /&gt; echo $USER&lt;BR /&gt; fi;;&lt;BR /&gt; 4) if (( $? == 0 ))&lt;BR /&gt; then&lt;BR /&gt; print -n "..Enter printer name :"&lt;BR /&gt; read prtr_name&lt;BR /&gt; print -n "You enter printer ${prtr_name}"&lt;BR /&gt; print -n " Is this correct Y/N "&lt;BR /&gt; read answ&lt;BR /&gt; if [[ "$answ" = [Yy] ]]&lt;BR /&gt; then&lt;BR /&gt; lpstat $prtr_name | grep $prtr_name | sort -k1 | cut -d " " -f1 &amp;gt; $prtr_name.out&lt;BR /&gt; for rem_prt in `cat $prtr_name.out`&lt;BR /&gt; do&lt;BR /&gt; cancel $rem_prt&lt;BR /&gt; done&lt;BR /&gt; else&lt;BR /&gt; echo "No Such Printer"&lt;BR /&gt; fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; fi;;&lt;BR /&gt; esac&lt;BR /&gt; done&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Aug 2008 17:58:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248082#M687470</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T17:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248083#M687471</link>
      <description>Hi (again) Charles:&lt;BR /&gt;&lt;BR /&gt;Ah, regarding you last post.  Put the following two lines at the top of your script and run it again :-)&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -u&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;The first line is good practice -- to declare the interpreter you want to use.  It avoids ambiguity.&lt;BR /&gt;&lt;BR /&gt;The second line exposes your error.&lt;BR /&gt;&lt;BR /&gt;Select an Option # from above: 5&lt;BR /&gt;Username to modify xxx&lt;BR /&gt;/tmp/0807[65]: TESTUSER: Parameter not set.&lt;BR /&gt;&lt;BR /&gt;Once again, you have TESTUSER and TESTNAME:&lt;BR /&gt;&lt;BR /&gt;# grep TEST /tmp/0807&lt;BR /&gt;TESTNAME=`awk -v USER=${USER} -F: '$1~USER { print $1 }' /etc/passwd`&lt;BR /&gt;if test "$USER" != "$TESTUSER"&lt;BR /&gt;&lt;BR /&gt;...consistency counts :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Aug 2008 18:07:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248083#M687471</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-07T18:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248084#M687472</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;I find set -x is useful as well in spotting scripting errors.&lt;BR /&gt;&lt;BR /&gt;Your last mistake is merely from experience and requires you merely to become familiar with the tools in this thread and use them in future scripting work.&lt;BR /&gt;&lt;BR /&gt;Very interesting thread BTW.&lt;BR /&gt;&lt;BR /&gt;Good luck with your debug.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 07 Aug 2008 18:13:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248084#M687472</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2008-08-07T18:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248085#M687473</link>
      <description>Steven Thanks for your input&lt;BR /&gt;&lt;BR /&gt;JHR&lt;BR /&gt;&lt;BR /&gt;Well I guess I am lost at this point. Trying to be constant&lt;BR /&gt;&lt;BR /&gt;Do I need to replace the TESTNAME with TEST USER?&lt;BR /&gt;Do I need to create this id. I guess I need to go back to the books and read. Good thing I have 3 months to have this written and ready.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;-Charlie&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Aug 2008 18:27:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248085#M687473</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T18:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248086#M687474</link>
      <description>Hi Charlies:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Do I need to replace the TESTNAME with TEST USER?&lt;BR /&gt;&lt;BR /&gt;Chose either name for your variable --- TESTNAME or TESTUSER.  If it was up to me, I'd use "TESTUSER" since you are comparing the value of ${TESTUSER} to ${USER}:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -u&lt;BR /&gt;echo "Username to modify \c"; read USER&lt;BR /&gt;TESTUSER=`awk -v USER=${USER} -F: '$1~USER { print $1 }' /etc/passwd`&lt;BR /&gt;if test "${USER}" != "${TESTUSER}"&lt;BR /&gt;then&lt;BR /&gt;      echo "${USER} is invalid!"&lt;BR /&gt;      echo "Press [ENTER] to continue. \c"&lt;BR /&gt;      read NOTHING&lt;BR /&gt;else&lt;BR /&gt;      echo   ${USER}&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...note that for good standards, I enclosed the variables in curly braces when I wanted to evaluate their value.  This is a good habit, in my opinion, to form, although it isn't required unless you do:&lt;BR /&gt;&lt;BR /&gt;# USER=charlie&lt;BR /&gt;# PASS=hisword&lt;BR /&gt;# echo $USER_$PASS&lt;BR /&gt;sh: USER_: Parameter not set.&lt;BR /&gt;# echo ${USER}_${PASS}&lt;BR /&gt;charlie_hisword&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 07 Aug 2008 18:35:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248086#M687474</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-08-07T18:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script input</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248087#M687475</link>
      <description>JRF&lt;BR /&gt;&lt;BR /&gt;Added everything ran it, was able to scroll up and see the results. no errors&lt;BR /&gt;&lt;BR /&gt;Now once this is done, and ran, I want to have it prompt me to change password or reset account would after the last line (see below)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; set -u&lt;BR /&gt;echo "Username to modify \c"; read USER&lt;BR /&gt;TESTUSER=`awk -v USER=${USER} -F: '$1~USER { print $1 }' /etc/passwd`&lt;BR /&gt;if test "${USER}" != "${TESTUSER}"&lt;BR /&gt;then&lt;BR /&gt;echo "${USER} is invalid!"&lt;BR /&gt;echo "Press [ENTER] to continue. \c"&lt;BR /&gt;read NOTHING&lt;BR /&gt;else&lt;BR /&gt;echo ${USER} &lt;BR /&gt;passwd</description>
      <pubDate>Thu, 07 Aug 2008 18:49:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-input/m-p/4248087#M687475</guid>
      <dc:creator>Charles Keyser</dc:creator>
      <dc:date>2008-08-07T18:49:06Z</dc:date>
    </item>
  </channel>
</rss>

