- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to mail passwd expire date
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2007 07:06 AM
11-28-2007 07:06 AM
I want to write a script for the following task
Check & notify user when the password will expire (some user may not login for anything but they will check there mail, so they need to be provided this information via mail. Otherwise, the root user will have to set their passwd each time they expire.)
Please guide me how to do this.
Thanks in advance
Regards
Thomas
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2007 07:51 AM
11-28-2007 07:51 AM
Re: script to mail passwd expire date
forum and a Tru64 forum. Perhaps you should
say which OS you're actually running.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2007 08:05 AM
11-28-2007 08:05 AM
Solutionbelwo script check username and send mail if expiration time is less than 15 day. it need perl . you can customize accoding your needs.
#!/usr/bin/sh
set -u
PATH=/usr/bin:/usr/sbin:/usr/lbin
integer exp_time
integer exp_date
integer current_time
integer last_change
integer time_left
integer days_left
integer seconds_per_day=86400
integer user_aging
user_aging=$(/usr/lbin/getprpw -r -m exptm $LOGNAME)
U=$(echo $LOGNAME|cut -c 1)
exp=$(logins -x -l $LOGNAME | tail -1 | awk '{print $4}')
((exp_time = exp * 86400))
current_time=$(/opt/perl/bin/perl -e "print time")
last_change=$(grep u_succhg /tcb/files/auth/$U/$LOGNAME | \
awk -F "u_succhg#" ' {print $2}' |\
awk -F ":" ' {print $1}' )
((exp_date = last_change + exp_time))
((time_left = exp_date - current_time))
((days_left = time_left / seconds_per_day))
last_change_date=$(getprpw -r -m spwchg $LOGNAME)
expire_date=$(/opt/perl/bin/perl -le 'print scalar localtime(('$exp_date'))')
if [ $days_left -lt 16 ]
then
echo "\n$LOGNAME expire: $expire_date days_left: $days_left" >> /home/root_mail.txt
continue
fi
mail $LOGNAME < /home/root_mail.txt
echo > /home/root_mail.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2007 08:05 AM
11-28-2007 08:05 AM
Re: script to mail passwd expire date
(asuming hp-ux)
If its any further help - assuming you have a trusted system, the following script will output last changed dates for all users. I can't get the expire date command option exptm to work on my system for as yet unknown reasons but you should be able to work out the expire date from the last changed date.
You should also look at the man pages for getprpw available courtesy of Stephan Farrely's answer here - http://forums.itrc.hp.com/cm/QuestionAnswer/0,,0xebf46c96588ad4118fef0090279cd0
f9,00.html
for USER in $(more /etc/passwd|cut -d":" -f1)
do
DATE=$(/usr/lbin/getprpw -r -m spwchg $USER)
echo "$USER:$DATE"
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2007 08:18 AM
11-28-2007 08:18 AM
Re: script to mail passwd expire date
Iam using HPUX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2007 09:34 AM
11-28-2007 09:34 AM
Re: script to mail passwd expire date
the Tru64 forum.
It rarely hurts to include the OS and version
in any question here, and sometimes it helps.