pwage-hpux-T for Trusted HPUX servers

I'm sharing this in case anybody needs it. Modified from the original solaris pwage script. This modified hpux script will check /etc/password file on hpux trusted systems search /tcb and grep the required u_succhg field. Calculate days to expiry and notify users via email.

original solaris pwage script: Check password age

for the hpux script you need to modify following

/etc/passwd file needs to have a "+email@domain.com" in the description field. You can use '+' or any other symbol but not sure if you can use another ':'

aixguy::114:106:aix administrator \+aixguy@unix.com:/home/aixguy:/usr/bin/sh
hpuxguy:
:103:106:hpux admin \+hpuxguy@unix.com:/home/hpuxguy:/usr/bin/sh
sparcguy:*:112:106:solaris administrator \+sparcguy@unix.com:/home/sparcguy:/usr/bin/ksh

MAXAGE=90 <-- we use 90 day expiry policy modify for yours.

If you want to test modify MAXAGE=0 or 10

do not run against un-trusted hpux boxes

Some points.

The normal secondary delimiter in the /etc/passwd comments field is a comma. Don't try a colon - it will corrupt the passwd file. The "usermod" command should stop you creating an invalid passwd file.

This is a dodgy construct because it can give false matches in any field. In the simple case, consider usernames called "fred", "freda" and "alfred". One extreme case would be a username called "home".
A safer version in the style of your script:

grep \^${i}: /etc/passwd |

On many O/S the "for i in <open ended list>" construct will collapse when the command line becomes too long for the CLI.

Just for interest in non-trusted HP-UX you can get all the base information for this type of script from the command:

logins -xto

thx for yur comments and suggestions mate feel free to modify or tighten to your requirements. :slight_smile:

working on an aix version, uses also the same concept will share it once have it.