<?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: shell script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5578749#M640381</link>
    <description>&lt;P&gt;I have half an answer for you.&amp;nbsp;&amp;nbsp; I put in a test at the bottom of my .profile for when I log in.&amp;nbsp; It is not perfect.&amp;nbsp; It is far from secure.&amp;nbsp; The program does not walk on water, or turn water into wine.&amp;nbsp;&amp;nbsp; It uses basic perl.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best of all.&amp;nbsp; It works for me.&amp;nbsp; It warns me if my password is close to expiring.&lt;/P&gt;&lt;P&gt;The missing part of your request?&amp;nbsp; The email you want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main key to this is the /usr/bin/passwd&amp;nbsp; -r files -s unix_login_name_here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if my unix login is Billy_bobby_billy_bo_bob, I run&lt;/P&gt;&lt;P&gt;/usr/bin/passwd -r file -s Billy_bobby_billy_bo_bob.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 86400 is 60 seconds times 60 minutes times 24 hours.&amp;nbsp; I.e. number of seconds per day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/perl
use Time::Local;
$WARN=14;
#___________________________________________________
# todays date
#________________________________________________________
( $T_sec, $T_min, $T_hour, $T_day, $T_mon, $T_year, @junk ) = localtime();
$T_epoch = timelocal( 0, $T_min, $T_hour, $T_day, $T_mon, $T_year);
($T_sec,$T_min,$T_hour,$T_day,$T_mon,$T_year,@junk ) = localtime($T_epoch);
$T_mon = $T_mon + 1;
$T_year = $T_year + 1900;
#print "Today is day $T_day month $T_mon yr $T_year\n";

#__________________________________________
# reset password date  R_xxxx
#__________________________________________
$CMD="\/usr\/bin\/passwd -r files -s $ENV{LOGNAME} |";
open(COMMAND, $CMD) || die "passwd cmd error";

while ( &amp;lt;COMMAND&amp;gt; ) {
  ( @line ) = split;
   if ( $#line == 4 ){
     if ( $line[3] &amp;lt; 10 and
          $line[4] &amp;gt; 50 and
          $line[4] &amp;lt; 80 and
          $line[1] eq "PS"  ) {
       # foreach $x (  @line ) { print "x is $x\n"; }
       # $line[0] name
       # $line[1] PS
       # $line[2] mm/dd/yy  $dline[0], $dline[1], $dline[2]
       # $line[3] &amp;lt; 10
       # $line[4] &amp;lt; 80 and &amp;gt; 50

       @dline = split(/\//, $line[2]);
       $R_epoch=timelocal( 0, 0, 0, $dline[1], $dline[0]-1, $dline[2]);
       $R_epoch=$R_epoch + ( $line[4] * 86400 );
       ($R_sec,$R_min,$R_hour,$R_day,$R_mon,$R_year ) = localtime($R_epoch);
       $R_mon++;
       $R_year = $R_year + 1900;
       #print "Password day $R_day month $R_mon yr $R_year\n";

       #------------------------------
       # Dday is the reset required date - warning days
       #------------------------------
       $D_epoch=$R_epoch - ( $WARN * 86400 );
       ($D_sec,$D_min,$D_hour,$D_day,$D_mon,$D_year ) = localtime($D_epoch);
       $D_mon++;
       $D_year = $D_year + 1900;
       #print "D-day        $D_day month $D_mon yr $D_year\n";

       if ( $T_epoch &amp;gt;= $D_epoch ) {
           print "User $ENV{LOGNAME}, You need to change our password soon.\n";
           printf("Today is day %02d/%02d/%04d\n", $T_mon, $T_day, $T_year);
           printf("Warn day is  %02d/%02d/%04d\n", $D_mon, $D_day, $D_year);
           printf("Password day %02d/%02d/%04d\n", $R_mon, $R_day, $R_year);
       } else {
           print "User $ENV{LOGNAME}, ";
           printf("the day your password dies is %02d/%02d/%04d\n",
                $R_mon, $R_day, $R_year);
       }
     }
   }
}
close(COMMAND);

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2012 18:10:15 GMT</pubDate>
    <dc:creator>Steve Post</dc:creator>
    <dc:date>2012-03-09T18:10:15Z</dc:date>
    <item>
      <title>shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5577139#M640380</link>
      <description>&lt;P&gt;i want to write a shell script&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is the output file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output&lt;/P&gt;&lt;P&gt;PS 030812 0 182 7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;request is the password reset date 030812 is the 8th march 2012&lt;/P&gt;&lt;P&gt;182&amp;nbsp; days is password age&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;we need to write a script for all user, when ever user reach 170 days we send one auto reply mail to user, regarding your password expire.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2012 10:47:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5577139#M640380</guid>
      <dc:creator>rajesh73</dc:creator>
      <dc:date>2012-03-08T10:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5578749#M640381</link>
      <description>&lt;P&gt;I have half an answer for you.&amp;nbsp;&amp;nbsp; I put in a test at the bottom of my .profile for when I log in.&amp;nbsp; It is not perfect.&amp;nbsp; It is far from secure.&amp;nbsp; The program does not walk on water, or turn water into wine.&amp;nbsp;&amp;nbsp; It uses basic perl.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best of all.&amp;nbsp; It works for me.&amp;nbsp; It warns me if my password is close to expiring.&lt;/P&gt;&lt;P&gt;The missing part of your request?&amp;nbsp; The email you want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main key to this is the /usr/bin/passwd&amp;nbsp; -r files -s unix_login_name_here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if my unix login is Billy_bobby_billy_bo_bob, I run&lt;/P&gt;&lt;P&gt;/usr/bin/passwd -r file -s Billy_bobby_billy_bo_bob.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 86400 is 60 seconds times 60 minutes times 24 hours.&amp;nbsp; I.e. number of seconds per day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/perl
use Time::Local;
$WARN=14;
#___________________________________________________
# todays date
#________________________________________________________
( $T_sec, $T_min, $T_hour, $T_day, $T_mon, $T_year, @junk ) = localtime();
$T_epoch = timelocal( 0, $T_min, $T_hour, $T_day, $T_mon, $T_year);
($T_sec,$T_min,$T_hour,$T_day,$T_mon,$T_year,@junk ) = localtime($T_epoch);
$T_mon = $T_mon + 1;
$T_year = $T_year + 1900;
#print "Today is day $T_day month $T_mon yr $T_year\n";

#__________________________________________
# reset password date  R_xxxx
#__________________________________________
$CMD="\/usr\/bin\/passwd -r files -s $ENV{LOGNAME} |";
open(COMMAND, $CMD) || die "passwd cmd error";

while ( &amp;lt;COMMAND&amp;gt; ) {
  ( @line ) = split;
   if ( $#line == 4 ){
     if ( $line[3] &amp;lt; 10 and
          $line[4] &amp;gt; 50 and
          $line[4] &amp;lt; 80 and
          $line[1] eq "PS"  ) {
       # foreach $x (  @line ) { print "x is $x\n"; }
       # $line[0] name
       # $line[1] PS
       # $line[2] mm/dd/yy  $dline[0], $dline[1], $dline[2]
       # $line[3] &amp;lt; 10
       # $line[4] &amp;lt; 80 and &amp;gt; 50

       @dline = split(/\//, $line[2]);
       $R_epoch=timelocal( 0, 0, 0, $dline[1], $dline[0]-1, $dline[2]);
       $R_epoch=$R_epoch + ( $line[4] * 86400 );
       ($R_sec,$R_min,$R_hour,$R_day,$R_mon,$R_year ) = localtime($R_epoch);
       $R_mon++;
       $R_year = $R_year + 1900;
       #print "Password day $R_day month $R_mon yr $R_year\n";

       #------------------------------
       # Dday is the reset required date - warning days
       #------------------------------
       $D_epoch=$R_epoch - ( $WARN * 86400 );
       ($D_sec,$D_min,$D_hour,$D_day,$D_mon,$D_year ) = localtime($D_epoch);
       $D_mon++;
       $D_year = $D_year + 1900;
       #print "D-day        $D_day month $D_mon yr $D_year\n";

       if ( $T_epoch &amp;gt;= $D_epoch ) {
           print "User $ENV{LOGNAME}, You need to change our password soon.\n";
           printf("Today is day %02d/%02d/%04d\n", $T_mon, $T_day, $T_year);
           printf("Warn day is  %02d/%02d/%04d\n", $D_mon, $D_day, $D_year);
           printf("Password day %02d/%02d/%04d\n", $R_mon, $R_day, $R_year);
       } else {
           print "User $ENV{LOGNAME}, ";
           printf("the day your password dies is %02d/%02d/%04d\n",
                $R_mon, $R_day, $R_year);
       }
     }
   }
}
close(COMMAND);

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2012 18:10:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/5578749#M640381</guid>
      <dc:creator>Steve Post</dc:creator>
      <dc:date>2012-03-09T18:10:15Z</dc:date>
    </item>
  </channel>
</rss>

