03-24-2011
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:
https://www.unix.com/shell-programmin...sword-age.html
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.
Quote:
#! /bin/sh
for i in `cat /etc/passwd | grep \@ | sed 's/:/+/g' | cut -d+ -f1`
do
Quote:
for j in `find /tcb -name $i -exec ls -1 {} \;`
do
LASTPWCHG=`cat $j | grep u_succhg | sed 's/:/#/g' | cut -d# -f3`
DAYSEC=`echo "60*60*24" | bc`
DAWNOFTIME=`/usr/contrib/bin/perl -e 'print int(time)'`
SECSAGO=`echo "$DAWNOFTIME - $LASTPWCHG" | bc`
DAYSAGO=`echo $SECSAGO/$DAYSEC | bc`
done
MAXAGE=90
LEFTDAYS=`echo "$MAXAGE - $DAYSAGO" | bc`
if [[ "$LEFTDAYS" = 7 ]]
then
EMAILID=`cat /etc/passwd | grep $i | sed 's/:/+/g' | cut -d+ -f6`
echo "Your unix id $i will expire in $LEFTDAYS days" | mailx -s "`uname -n` Password aging Reminder" $EMAILID
fi
if [[ "$LEFTDAYS" = 3 ]]
then
EMAILID=`cat /etc/passwd | grep $i | sed 's/:/+/g' | cut -d+ -f6`
echo "Your unix id $i will expire in $LEFTDAYS days" | mailx -s "`uname -n` Password aging Reminder" $EMAILID
fi
if [[ "$LEFTDAYS" -lt 0 ]]
then
EMAILID=`cat /etc/passwd | grep $i | sed 's/:/+/g' | cut -d+ -f6`
echo "Please note that your unix id $i has aleaady expired" | mailx -s "`uname -n` Password aging Reminder" $EMAILID
fi
done
If you want to test modify MAXAGE=0 or 10
do not run against un-trusted hpux boxes
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Is there any problems of binaries compatibility between HPUX 10.20 et 11 ? (2 Replies)
Discussion started by: Olivier
2 Replies
2. HP-UX
:( i got couple of weeks ago a : HP Visualize workstation , model B100.
everithing is ok in the box the only problem is that i 'am not familiar with this operational sys, and i try to uninstall and see if i can get on it windows net server 64 bit. or any other 64 bit operational sys that i'll... (1 Reply)
Discussion started by: newbird
1 Replies
3. UNIX for Dummies Questions & Answers
Hi,
I am a SAP Basis admin recentely been asked to administer a HPUX server. Could someone recommend some good study material to learn with the Sap
prespective.
-carry (1 Reply)
Discussion started by: carryclare
1 Replies
4. UNIX and Linux Applications
Hi
can any tell where we can get RPM files for HPUX OS
RPM file can be of any application ,it should be succesfully installed in the
machine
Regards
Harish Kumar :confused: (2 Replies)
Discussion started by: harishkumar
2 Replies
5. Shell Programming and Scripting
I am running HPUX and using WLM (workload manager). I want to write a script to fork CPUs to basically take CPUs from other servers to show that the communication is working and CPU licensing is working. Basically, I want to build a script that will use up CPU on a server. Any ideas? (2 Replies)
Discussion started by: cpolikowsky
2 Replies
6. Shell Programming and Scripting
Hello.
I cant figure out how can i move entire row up , so it pasted on the one above at the end , or to do that for one character.
In notepads,word, or some other text editors we would do that with backspace button.
Example.
Content of my text file is this :
I am trying to do
that.
And... (2 Replies)
Discussion started by: tonijel
2 Replies
7. UNIX and Linux Applications
Hi,
We've got a samba server running in our DMZ. Our users drag & drop files on it for vendors. Everything was working perfectly until the powers that be decided to build a trust between a couple of internal domains.
Samba is now querying each server in the trust. When a user browses... (5 Replies)
Discussion started by: mph
5 Replies
8. AIX
This is the password aging script for aix just completed. So far tested and still testing on one of our aix server running 5.3.0.0. So anyway as you can see it is very similar to pwage-hpux-T the only difference on aix /etc/passwd file looks in this format. Also for this script to work you need to... (0 Replies)
Discussion started by: sparcguy
0 Replies
9. Shell Programming and Scripting
Hello All
Why is hpux is not much spoken in the unix/Linux platform. what is the disadvantes in HPUX
Thanks,
VJ (1 Reply)
Discussion started by: Vijaykannan T
1 Replies
10. HP-UX
is there a way for my C++ application to find out which mode the hpux OS is running in?
standard mode or trusted mode. (3 Replies)
Discussion started by: einsteinBrain
3 Replies
LEARN ABOUT DEBIAN
envpath
ENVPATH(1p) User Contributed Perl Documentation ENVPATH(1p)
NAME
envpath - Advanced operations on path variables
SYNOPSIS
Run this script with the "-help" option for usage details.
DESCRIPTION
Parses the command line, modifies the specified path variable(s), and execs the remaining arguments. There are two modes, simple and
advanced:
SIMPLE MODE
Simple mode presents an alternative, platform-independent syntax for specifying paths wherein the path separator is "," and environment
variables can be expanded with @NAME@. For example
envpath PATH=@PATH@,/usr/ucb -- printenv PATH
appends "/usr/ucb" to $PATH and execs printenv PATH. The "--" is optional.
You can also specify prepending or appending by using "+=" or "=+" respectively:
# place /usr/ucb at the front
envpath PATH+=/usr/ucb -- printenv PATH
# place /usr/ucb at the back
envpath PATH=+/usr/ucb -- printenv PATH
Simple mode requires only this script; it does not require Env::Path to be installed.
ADVANCED MODE
Advanced mode basically provides command-line access to the features of Env::Path (see), which must be installed. The "-E" flag selects the
path variable to operate on and other flags specify operations on it. E.g.
envpath -E MANPATH -A /tmp -R /usr/share/man -N -U -- man ...
would take MANPATH, append /tmp to it, remove any references to "/usr/share/man", remove any dirs which don't exist ("-N") and remove
redundant entries ("-U") before running man.
The -Whence option allows patterns. Thus
envpath -W "cat*"
would find all programs on PATH which match cat*.
CLEARCASE WINKINS
A big part of the motivation for this script was for use with ClearCase builds; iff you know or care about ClearCase read on. Typically,
during builds (and not just with ClearCase), pathvars such as PATH, CLASSPATH, and LD_LIBRARY_PATH must be strictly controlled. One choice
is to force static values of these into the environment during the build process, another is to simply require/expect users to set their
paths appropriately. Each of these can lead to subtle build or runtime errors, however, and makes it hard for new users to get up to speed
since their personal environment must be just so.
Another common choice is to use only full pathnames within the Makefile, avoiding reliance on search paths at all. This is often the best
way to go but can suppress ClearCase winkins. For example, say you're generating ascii files of some type with a binary executable you
just built:
$(INCDIR)/foo.h: $(BINDIR)/foomaker $(BINDIR)/foomaker ...
The problem with this is that $(BINDIR) likely contains a platform part such as 'solaris' or 'hpux', which makes it impossible to wink in
the foo.h file on other platforms even though it's ascii. This same thing could come up even with a standard pre-built utility that's in
different places on different platforms; "yacc", for instance, is in /usr/bin on Linux and /usr/ccs/bin on Solaris.
You could modify the path on the fly:
$(INCDIR)/foo.h: $(BINDIR)/foomaker PATH=$(BINDIR)$(SEP)$$PATH foomaker ...
but this suffers from the same problem: since $(BINDIR) and $PATH are expanded literally within the build script they'll suppress winkins.
Here's a solution using envpath:
$(INCDIR)/foo.h: $(BINDIR)/foomaker envpath PATH=@BINDIR@,@PATH@ foomaker ...
This hides the evaluation of BINDIR and PATH such that clearmake never sees anything but the literals, thus clearing the field for winkins.
Of course envpath is capable of doing more than this, but it's the original reason it was written.
AUTHOR
David Boyce <dsbperl AT boyski.com>
COPYRIGHT
Copyright (c) 2000-2001 David Boyce. All rights reserved. This Perl program is free software; you may redistribute and/or modify it under
the same terms as Perl itself.
SEE ALSO
perl(1), "perldoc Env::Path"
perl v5.10.1 2003-10-10 ENVPATH(1p)