- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- date calculation/conversion help needed
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
Discussions
Discussions
Discussions
Forums
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
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
тАО05-21-2004 02:43 AM
тАО05-21-2004 02:43 AM
date calculation/conversion help needed
The third field shows the date of the last modification date of their password. If I add 89 days to it, I'll have the exact date the password will expire. I intend to send a e-mail to a user 14 days prior to the account expiring. I also plan to have an e-mail sent every day after the 14 day mark reminding the user if the password hasn't been changed.
Can someone suggest a way for me to calculate the date using the format used by running passwd -sa?
Here's an example output:
emxadm PS 04/27/04 0 90 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 03:02 AM
тАО05-21-2004 03:02 AM
Re: date calculation/conversion help needed
http://www.hpux.ws/merijn/caljd.pl
Two great utilities that I use for date calculations.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 03:03 AM
тАО05-21-2004 03:03 AM
Re: date calculation/conversion help needed
I'll get back to you with questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 03:36 AM
тАО05-21-2004 03:36 AM
Re: date calculation/conversion help needed
passwd -sa | awk '{if $3 ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}' | while read DT
do
DT89=$(caljd.sh -C -S "/" $(caljd.sh -c -S "/" -C -n 89 ${DT}))
echo "${DT} --> ${DT89}"
done
If I haven't made any of them there typo's that there should do it. You will need a fairly new version of caljd.sh to convert 2 digit years into 4 digit recent years (-C argument).
Here is a version of caljd.sh that will suffice. Invoke as caljd.sh -u for full usage and examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 05:24 AM
тАО05-21-2004 05:24 AM
Re: date calculation/conversion help needed
# ./sa
+ passwd -sa
+ read DT
+ awk {if $3 ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}
syntax error The source line is 1.
The error context is
{if >>> $3 <<< ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}
awk: The statement cannot be correctly parsed.
The source line is 1.
awk: There is an extra ) character.
I don't know enough about what's going on in it to debug. Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 06:04 AM
тАО05-21-2004 06:04 AM
Re: date calculation/conversion help needed
'{if $3 ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}'
should be:
'{if ($3 ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}'
Let him out with that there syntax and let's see if that dog will hunt now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 06:53 AM
тАО05-21-2004 06:53 AM
Re: date calculation/conversion help needed
# ./sa
12/30/03 --> 03/28/04
05/11/04 --> 08/08/04
12/01/03 --> 02/28/04
12/16/03 --> 03/14/04
08/02/02 --> 10/30/02
02/11/04 --> 05/10/04
00/00/00 --> 02/27/00
00/00/00 --> 02/27/00
00/00/00 --> 02/27/00
12/16/03 --> 03/14/04
01/13/04 --> 04/11/04
00/00/00 --> 02/27/00
00/00/00 --> 02/27/00
05/20/04 --> 08/17/04
04/03/03 --> 07/01/03
04/27/04 --> 07/25/04
03/16/04 --> 06/13/04
I really appreciate your time on this. I only have one other request, if I may be permitted to do so. Can you help me get this to work in Korn? I'd like to use it on other platforms.
When I get the final script completed I'll post it here and share it with you all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 07:29 AM
тАО05-21-2004 07:29 AM
Re: date calculation/conversion help needed
The code that invokes awk in the sample script does nothing special so awk, oawk, nawk, or gawk should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 07:47 AM
тАО05-21-2004 07:47 AM
Re: date calculation/conversion help needed
I changed caljd.sh to read #!/usr/bin/ksh
and the sa script to the same:
# vi sa
"sa" 7 lines, 206 characters
#!/usr/bin/ksh
set -x
passwd -sa | awk '{if ($3 ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}' | while read DT
do
DT89=$(caljd.sh -C -S "/" $(caljd.sh -c -S "/" -C -n 89 ${DT}))
echo "${DT} --> ${DT89}"
done
I get this now:
# ./sa
+ passwd -sa
+ read DT
+ awk {if ($3 ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}
awk: syntax error near line 1
awk: illegal statement near line 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 08:36 AM
тАО05-21-2004 08:36 AM
Re: date calculation/conversion help needed
the regular expression is looking for exactly 2 digits
passwd -sa | awk '{if ($3 ~ "[0-9]{2}/[0-9]{2}/[0-9]{2}") print $3}'
change it to:
passwd -sa | awk '{if ($3 ~ "[0-9][0-9]/[0-9][0-9]/[0-9][0-9]") print $3}'
AND if that doesn't work change awk to nawk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-24-2004 07:33 AM
тАО05-24-2004 07:33 AM
Re: date calculation/conversion help needed
I also changed awk to nawk in your last suggestion and it now works in Sol5.8