- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Date command
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
08-22-2003 02:41 PM
08-22-2003 02:41 PM
like "date +%s" in linux.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 03:16 PM
08-22-2003 03:16 PM
Re: Date command
$ perl -e 'print time;'
or
$ perl -e 'print time,"\n"'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 03:20 PM
08-22-2003 03:20 PM
Re: Date command
It worked!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 03:54 PM
08-22-2003 03:54 PM
Re: Date command
But I have another HP machine which doesnt have perl installed and this command didnt work there as you said.
Now I have a script which does the same thing.
But that only works for SUN.
#!/bin/sh
FILE=/temp/abcd.time
touch $FILE
(
echo 10 o 8 i
echo $FILE | /usr/bin/cpio -o -H odc 2>/dev/null | /usr/bin/cut -c50-59
echo p
) | /usr/bin/dc
/usr/bin/rm -f /tmp/abcd.time
For HP it gives the error as "Empty Stack".
How do I get over with this problem.
Any suggestions would help.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 04:54 PM
08-22-2003 04:54 PM
Re: Date command
want to do this"? Perhaps there's an easier
route to go.
It is relatively straightforward and portable to
write a short C program to get the time in the
format you want:
#include
#include
int main() {
printf("%d\n", time(NULL));
return(0);
}
Compile this and install it on the machine as
/usr/local/bin/gettimestamp or somesuch.
Then just call it from your script.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2003 12:07 AM
08-24-2003 12:07 AM
Solutionyou can modify your script to something like this on hpux:
#!/usr/bin/sh
FILE=/tmp/abcd.time
touch $FILE
HEADER=$(echo $FILE | /usr/bin/cpio -o -c 2>/dev/null)
(
echo 10 o 8 i
echo "$HEADER" | /usr/bin/cut -c50-59
echo p
) | /usr/bin/dc
/usr/bin/rm -f /tmp/abcd.time
# end of script
On my system it gives this result:
1061711793
which can be converted it into something more human this way:
# SECS=1061711793
# echo 0d${SECS}=Y|adb
2003 Aug 24 09:56:33
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2003 01:48 AM
08-24-2003 01:48 AM
Re: Date command
For HP-UX, you can get precompiled binaries from the HP Porting Centers (http://hpux.connect.org.uk/ amongst many) or my HP ITRC site (http://www.cmve.net/~merijn or https://www.beepz.com/personal/merijn). For Sun (and other OS's) links to precompiled binaries can be found here (http://www.cpan.org/ports/)
If possible, I'd advise you to take a recent port, like 5.8.0 (current latest stable), because that assures all examples posted here to actually work.
Enjoy, have FUN! H.Merijn