- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- Re: How to get current date/time as seconds since ...
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
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
тАО12-05-2005 03:59 AM
тАО12-05-2005 03:59 AM
How to get current date/time as seconds since Epoch in Perl
Sorry if this is a simple question with an obvious answer but I've never done any programming in Perl.
I have a script written in Perl where I need to get the current date/time in seconds since Epoch. How would I do this?
I've used the following to get the date string given the seconds since Epoch:
_ntfytme=1133799166
_strg="print scalar localtime($_ntfytme)"
_ntfydte=`/usr/bin/perl -e "$_strg"`
So I assume that localtime might work but haven't been able to find the manpage for it.
Thanks in advance for any help.
Vic
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2005 09:33 PM
тАО12-05-2005 09:33 PM
Re: How to get current date/time as seconds since Epoch in Perl
is there an spcific problem you have in mind?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2005 11:58 PM
тАО12-05-2005 11:58 PM
Re: How to get current date/time as seconds since Epoch in Perl
A few years ago a consultant wrote us a script in Perl that allows certain users to manage accounts within their group.
One of its functions is to change password. When it does it makes sure that the account isn't locked with:
system("/usr/sbin/usermod -x administrative_lock_applied=0 $NUSER");
It appears not to work properly when the password is just expired. In dxaccounts that's when a red circle with a white X in it appears next to the user icon (I think).
What I think is missing is the u_succhg field has to be updated with the current date/time in seconds since Epoch. That's why I asked.
Thanks,
Vic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2005 03:17 AM
тАО12-06-2005 03:17 AM
Re: How to get current date/time as seconds since Epoch in Perl
system("/usr/sbin/usermod -x grace_limit=1 $NUSER");
This should work if the password is expired, but will not work if the account is expired.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2005 03:34 AM
тАО12-06-2005 03:34 AM
Re: How to get current date/time as seconds since Epoch in Perl
Thanks for the reply. One question, what's the difference between an expired password and an expired account.
Thanks,
Vic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2005 04:25 AM
тАО12-06-2005 04:25 AM
Re: How to get current date/time as seconds since Epoch in Perl
Ann
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2005 05:17 AM
тАО12-06-2005 05:17 AM
Re: How to get current date/time as seconds since Epoch in Perl
what are you using to change the password?
Maybe it is not necessary to change the u_succhg?
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2005 05:40 AM
тАО12-06-2005 05:40 AM
Re: How to get current date/time as seconds since Epoch in Perl
Thanks for the info, I wasn't aware of the distinction. We've always allowed the password expiration date to, in a sense, expire the account.
Michael,
Again, a consultant wrote this Perl script and I don't know Perl. From what I can gather it manually encrypts the password entered by the user with the 'crypt' function and then updates the u_pwd field.
Anyway, I found out for someone that to get what I wanted in Perl it is:
my $epoc=time();
Simple enough. I've made the necessary changes, crossed my fingers, and tried it. It works.
I'm sure there's better ways of doing this but right now I've got other more pressing problems to look at, like Legato backups that start before the precmd finishes.
Thanks,
Vic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2005 06:37 AM
тАО12-06-2005 06:37 AM
Re: How to get current date/time as seconds since Epoch in Perl
Manually encrypting the password with crypt isn't the best way to do this. It limits you to using crypt which is one of the reasons why people enable Enhanced Security, to allow other encryption methods. It would be better to figure out a way to either use the usermod command to change the password or call out from the perl to the sia_change_password() c routine. Something to look into when you have some free time :)
To fix your current problem it looks like updating u_succhg is the best way to handle it.
Ann
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2005 01:01 AM
тАО12-07-2005 01:01 AM
Re: How to get current date/time as seconds since Epoch in Perl
Thanks for the information but where I work, "When I have some free time" usually means "It ain't gonna happen". :)
Happy Holidays,
Vic