<?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 Password ageing script problem !!! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/password-ageing-script-problem/m-p/4571671#M679158</link>
    <description>I have a standard password aging script on our hpux boxes. The script sends mail when the password aging is less then 9 days.&lt;BR /&gt;&lt;BR /&gt;Problem:- I have amended mailx command in towards the end. The script is sending multiple mails since the script has for loop in it. &lt;BR /&gt;It sends mail as many mails as per the users in the userlist and appends the users name in the corresponding mail&lt;BR /&gt;&lt;BR /&gt;Below is the script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;# Show users in a trusted system whose passwords are about to expire&lt;BR /&gt;# Reset the u_succhg (spwchg) last successful password change time&lt;BR /&gt;&lt;BR /&gt;set -u&lt;BR /&gt;PATH=/usr/bin:/usr/sbin:/usr/lbin&lt;BR /&gt;HOST=`uname -n`&lt;BR /&gt;REPORT_FILE="/var/tmp/user_expiry_dba.rpt"&lt;BR /&gt;&lt;BR /&gt;echo "\n`date`\n\n" &amp;gt; $REPORT_FILE&lt;BR /&gt;&lt;BR /&gt;integer exp_time&lt;BR /&gt;integer exp_date&lt;BR /&gt;integer current_time&lt;BR /&gt;integer last_change&lt;BR /&gt;integer time_left&lt;BR /&gt;integer days_left&lt;BR /&gt;integer seconds_per_day=86400&lt;BR /&gt;integer system_wide_aging&lt;BR /&gt;integer user_aging&lt;BR /&gt;&lt;BR /&gt;NOTTRUSTED=/sbin/true&lt;BR /&gt;if [ -x /usr/lbin/modprpw ]&lt;BR /&gt;then&lt;BR /&gt;modprpw 1&amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [ $? -eq 2 ]&lt;BR /&gt;then&lt;BR /&gt;NOTTRUSTED=/sbin/false&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if $NOTTRUSTED&lt;BR /&gt;then&lt;BR /&gt;print "\n This system is not a Trusted System"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;system_wide_aging=$(/usr/lbin/getprdef -r -m exptm)&lt;BR /&gt;if [ $system_wide_aging -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;print "System wide password aging is disabled on $HOST.\n"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;system_wide_aging=$(/usr/lbin/getprdef -r -m exptm)&lt;BR /&gt;if [ $system_wide_aging -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;print "System wide password aging is disabled on $HOST.\n"&lt;BR /&gt;else&lt;BR /&gt;print "System wide password aging is enabled on $HOST.\n"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for USER in $(cat /sysadmin/scripts/user_list_dba)&lt;BR /&gt;do&lt;BR /&gt;user_aging=$(/usr/lbin/getprpw -r -m exptm $USER)&lt;BR /&gt;if [ $user_aging -eq "0" ]&lt;BR /&gt;then&lt;BR /&gt;print "\nUser $USER does not have password aging enabled."&lt;BR /&gt;continue&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $system_wide_aging -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;if [ $user_aging -eq "-1" ]&lt;BR /&gt;then&lt;BR /&gt;print "\nUser $USER does not have password aging enabled."&lt;BR /&gt;continue&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;U=$(echo $USER|cut -c 1)&lt;BR /&gt;&lt;BR /&gt;exp=$(logins -x -l $USER | tail -1 | awk '{print $4}')&lt;BR /&gt;((exp_time = exp * 86400))&lt;BR /&gt;current_time=$(/sysadmin/scripts/time)&lt;BR /&gt;&lt;BR /&gt;passwd_changed=$(grep u_succhg /tcb/files/auth/$U/$USER)&lt;BR /&gt;if [ $? = 1 ]&lt;BR /&gt;then&lt;BR /&gt;echo "User $USER : password expired\n\n" &amp;gt;&amp;gt; $REPORT_FILE&lt;BR /&gt;print "\nUser $USER does not have valid last successful password"&lt;BR /&gt;print "change date. This can happen if tsconvert is used on"&lt;BR /&gt;print "the command line to convert the system, instead of SAM."&lt;BR /&gt;continue&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;last_change=$(grep u_succhg /tcb/files/auth/$U/$USER | \&lt;BR /&gt;awk -F "u_succhg#" ' {print $2}' |\&lt;BR /&gt;awk -F ":" ' {print $1}' )&lt;BR /&gt;&lt;BR /&gt;((exp_date = last_change + exp_time))&lt;BR /&gt;((time_left = exp_date - current_time))&lt;BR /&gt;((days_left = time_left / seconds_per_day))&lt;BR /&gt;&lt;BR /&gt;last_change_date=$(getprpw -r -m spwchg $USER)&lt;BR /&gt;expire_date=$(echo 0d${exp_date}=Y | adb -o | cut -c 17-27)&lt;BR /&gt;&lt;BR /&gt;# if [ $days_left -gt 1 ]&lt;BR /&gt;&lt;BR /&gt;if [ $days_left -lt 9 ]&lt;BR /&gt;then&lt;BR /&gt;print "User $USER on $HOST has $days_left days left until password expires."&lt;BR /&gt;print "User $USER on $HOST last changed the password on: $last_change_date."&lt;BR /&gt;print "User $USER on $HOST - password will expire on: $expire_date.\n"&lt;BR /&gt;echo "User $USER : password will expire on $expire_date\n\n" &amp;gt;&amp;gt; $REPORT_FILE&lt;BR /&gt;MAILTO="kamshiv@rediffmail.com"&lt;BR /&gt;# mailx -s "CGHRPRODDB Password_Status" $MAILTO &amp;lt; $REPORT_FILE&lt;BR /&gt;read&lt;BR /&gt;echo "Sending mail"&lt;BR /&gt;mailx -s "TESTING PLEASE IGNORE" $MAILTO &amp;lt; $REPORT_FILE&lt;BR /&gt;echo "Mail sent"&lt;BR /&gt;read&lt;BR /&gt;else&lt;BR /&gt;print "User $USER: password will expire within one day.\n"&lt;BR /&gt;echo "User $USER : password expired\n\n" &amp;gt;&amp;gt; $REPORT_FILE&lt;BR /&gt;echo "Sending mail"&lt;BR /&gt;MAILTO="kamshiv@rediffmail.com"&lt;BR /&gt;mailx -s "TESTING PLEASE IGNORE" $MAILTO &amp;lt; $REPORT_FILE&lt;BR /&gt;echo "Mail sent"&lt;BR /&gt;&lt;BR /&gt;# modprpw -l -v $USER&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kindly assist with your inputs.</description>
    <pubDate>Tue, 26 Jan 2010 17:33:24 GMT</pubDate>
    <dc:creator>kpatel786</dc:creator>
    <dc:date>2010-01-26T17:33:24Z</dc:date>
    <item>
      <title>Password ageing script problem !!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/password-ageing-script-problem/m-p/4571671#M679158</link>
      <description>I have a standard password aging script on our hpux boxes. The script sends mail when the password aging is less then 9 days.&lt;BR /&gt;&lt;BR /&gt;Problem:- I have amended mailx command in towards the end. The script is sending multiple mails since the script has for loop in it. &lt;BR /&gt;It sends mail as many mails as per the users in the userlist and appends the users name in the corresponding mail&lt;BR /&gt;&lt;BR /&gt;Below is the script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;# Show users in a trusted system whose passwords are about to expire&lt;BR /&gt;# Reset the u_succhg (spwchg) last successful password change time&lt;BR /&gt;&lt;BR /&gt;set -u&lt;BR /&gt;PATH=/usr/bin:/usr/sbin:/usr/lbin&lt;BR /&gt;HOST=`uname -n`&lt;BR /&gt;REPORT_FILE="/var/tmp/user_expiry_dba.rpt"&lt;BR /&gt;&lt;BR /&gt;echo "\n`date`\n\n" &amp;gt; $REPORT_FILE&lt;BR /&gt;&lt;BR /&gt;integer exp_time&lt;BR /&gt;integer exp_date&lt;BR /&gt;integer current_time&lt;BR /&gt;integer last_change&lt;BR /&gt;integer time_left&lt;BR /&gt;integer days_left&lt;BR /&gt;integer seconds_per_day=86400&lt;BR /&gt;integer system_wide_aging&lt;BR /&gt;integer user_aging&lt;BR /&gt;&lt;BR /&gt;NOTTRUSTED=/sbin/true&lt;BR /&gt;if [ -x /usr/lbin/modprpw ]&lt;BR /&gt;then&lt;BR /&gt;modprpw 1&amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;if [ $? -eq 2 ]&lt;BR /&gt;then&lt;BR /&gt;NOTTRUSTED=/sbin/false&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if $NOTTRUSTED&lt;BR /&gt;then&lt;BR /&gt;print "\n This system is not a Trusted System"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;system_wide_aging=$(/usr/lbin/getprdef -r -m exptm)&lt;BR /&gt;if [ $system_wide_aging -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;print "System wide password aging is disabled on $HOST.\n"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;system_wide_aging=$(/usr/lbin/getprdef -r -m exptm)&lt;BR /&gt;if [ $system_wide_aging -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;print "System wide password aging is disabled on $HOST.\n"&lt;BR /&gt;else&lt;BR /&gt;print "System wide password aging is enabled on $HOST.\n"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;for USER in $(cat /sysadmin/scripts/user_list_dba)&lt;BR /&gt;do&lt;BR /&gt;user_aging=$(/usr/lbin/getprpw -r -m exptm $USER)&lt;BR /&gt;if [ $user_aging -eq "0" ]&lt;BR /&gt;then&lt;BR /&gt;print "\nUser $USER does not have password aging enabled."&lt;BR /&gt;continue&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;if [ $system_wide_aging -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;if [ $user_aging -eq "-1" ]&lt;BR /&gt;then&lt;BR /&gt;print "\nUser $USER does not have password aging enabled."&lt;BR /&gt;continue&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;U=$(echo $USER|cut -c 1)&lt;BR /&gt;&lt;BR /&gt;exp=$(logins -x -l $USER | tail -1 | awk '{print $4}')&lt;BR /&gt;((exp_time = exp * 86400))&lt;BR /&gt;current_time=$(/sysadmin/scripts/time)&lt;BR /&gt;&lt;BR /&gt;passwd_changed=$(grep u_succhg /tcb/files/auth/$U/$USER)&lt;BR /&gt;if [ $? = 1 ]&lt;BR /&gt;then&lt;BR /&gt;echo "User $USER : password expired\n\n" &amp;gt;&amp;gt; $REPORT_FILE&lt;BR /&gt;print "\nUser $USER does not have valid last successful password"&lt;BR /&gt;print "change date. This can happen if tsconvert is used on"&lt;BR /&gt;print "the command line to convert the system, instead of SAM."&lt;BR /&gt;continue&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;last_change=$(grep u_succhg /tcb/files/auth/$U/$USER | \&lt;BR /&gt;awk -F "u_succhg#" ' {print $2}' |\&lt;BR /&gt;awk -F ":" ' {print $1}' )&lt;BR /&gt;&lt;BR /&gt;((exp_date = last_change + exp_time))&lt;BR /&gt;((time_left = exp_date - current_time))&lt;BR /&gt;((days_left = time_left / seconds_per_day))&lt;BR /&gt;&lt;BR /&gt;last_change_date=$(getprpw -r -m spwchg $USER)&lt;BR /&gt;expire_date=$(echo 0d${exp_date}=Y | adb -o | cut -c 17-27)&lt;BR /&gt;&lt;BR /&gt;# if [ $days_left -gt 1 ]&lt;BR /&gt;&lt;BR /&gt;if [ $days_left -lt 9 ]&lt;BR /&gt;then&lt;BR /&gt;print "User $USER on $HOST has $days_left days left until password expires."&lt;BR /&gt;print "User $USER on $HOST last changed the password on: $last_change_date."&lt;BR /&gt;print "User $USER on $HOST - password will expire on: $expire_date.\n"&lt;BR /&gt;echo "User $USER : password will expire on $expire_date\n\n" &amp;gt;&amp;gt; $REPORT_FILE&lt;BR /&gt;MAILTO="kamshiv@rediffmail.com"&lt;BR /&gt;# mailx -s "CGHRPRODDB Password_Status" $MAILTO &amp;lt; $REPORT_FILE&lt;BR /&gt;read&lt;BR /&gt;echo "Sending mail"&lt;BR /&gt;mailx -s "TESTING PLEASE IGNORE" $MAILTO &amp;lt; $REPORT_FILE&lt;BR /&gt;echo "Mail sent"&lt;BR /&gt;read&lt;BR /&gt;else&lt;BR /&gt;print "User $USER: password will expire within one day.\n"&lt;BR /&gt;echo "User $USER : password expired\n\n" &amp;gt;&amp;gt; $REPORT_FILE&lt;BR /&gt;echo "Sending mail"&lt;BR /&gt;MAILTO="kamshiv@rediffmail.com"&lt;BR /&gt;mailx -s "TESTING PLEASE IGNORE" $MAILTO &amp;lt; $REPORT_FILE&lt;BR /&gt;echo "Mail sent"&lt;BR /&gt;&lt;BR /&gt;# modprpw -l -v $USER&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kindly assist with your inputs.</description>
      <pubDate>Tue, 26 Jan 2010 17:33:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/password-ageing-script-problem/m-p/4571671#M679158</guid>
      <dc:creator>kpatel786</dc:creator>
      <dc:date>2010-01-26T17:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Password ageing script problem !!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/password-ageing-script-problem/m-p/4571672#M679159</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Take a look at this:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://hpux.ws/mailfile2" target="_blank"&gt;http://hpux.ws/mailfile2&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Write your script output to a file or the email body set by this script. Then you can attach the report if you want.&lt;BR /&gt;&lt;BR /&gt;This is a production script.&lt;BR /&gt;&lt;BR /&gt;If you want debug help on your script, then please provide the error message.&lt;BR /&gt;&lt;BR /&gt;Your problem may also be solved by running your user list through sort -u (unique)&lt;BR /&gt;&lt;BR /&gt;Otherwise its a loop control issue and you will need to put write statements to find out which loop condition is not working as expected, resulting in multiple mails.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 26 Jan 2010 18:03:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/password-ageing-script-problem/m-p/4571672#M679159</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2010-01-26T18:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Password ageing script problem !!!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/password-ageing-script-problem/m-p/4571673#M679160</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Move your 'mailx' to after the 'done' of the loop; that is, after all users have been examined.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 26 Jan 2010 18:10:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/password-ageing-script-problem/m-p/4571673#M679160</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-01-26T18:10:52Z</dc:date>
    </item>
  </channel>
</rss>

