The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
date -d nightmare on Solaris pavanlimo SUN Solaris 1 04-02-2009 11:34 AM
LTO Compatibility Shawn Paul HP-UX 2 09-29-2008 03:24 AM
About compatibility of HP-UX 11i Irene Martínez HP-UX 0 02-29-2008 01:05 PM
Disks compatibility ppass SUN Solaris 0 12-05-2007 05:00 AM
compatibility problem ??!! oti Shell Programming and Scripting 3 05-17-2002 07:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-02-2009
pavanlimo pavanlimo is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 10
Unhappy date -d compatibility on Solaris

Hello there ppl,
I thought my question would qualify to be posted in this forum and in Solaris forum.

And I swear to God.. there is no discussion on this exact topic anywhere else on the web!

So my script on BASH uses 2 commands:

1) date -d "Fri Mar 06 10:18:16 UTC 2009" +%s

This command converts the specified time into localtime(with local timezone) and then into epoch(number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970).

2) date -d "last Sunday" +%s

This command gives the time in epoch of the immediately previous Sunday.

Now I'm clueless about how to make my script compatible with Solaris.
Some pointers I found through google, not much of a help :|.
They suggested me to use

perl -e "print time;"

This prints only the current epoch time, doesn't take 'time' as input, let alone "last Sunday" as input.

So.. guys who would help solve these 2 cases will win a free lifetime holiday to mars!
Really!

No, seriously, I would appreciate any help, whatsoever.
  #2 (permalink)  
Old 04-02-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
It is not bash you need, it is GNU date. Those extensions are part of the date program that comes with most versions of Linux.

If you have Solaris the GNU core utilities are available for it, free of charge.

Sunfreeware - Freeware Open Source Software for Sun Microsystem's Solaris
Select your version of Solaris and download what you want.
  #3 (permalink)  
Old 04-02-2009
TonyFullerMalv's Avatar
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Location: Malvern, Worcs. U.K.
Posts: 730
Or else use what I had to do and that is write a perl script to translate date to epoch, e.g. the one at:
http://www.cpan.org/authors/id/J/JM/JMATES/date2epoch

I would have had trouble installing a GNU date command but already had perl!
  #4 (permalink)  
Old 04-03-2009
pavanlimo pavanlimo is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 10
Thanks Jim, Tony for your super quick replies.

Jim, installing GNU utilities is not an option if this script is shipped to a customer. Since we can't expect the customer to install the utilities.

Tony, your solution solves one of my two problems, however, it would be great if we can find a solution without having to create a separate perl file.

Guess 'm still in rough state :|.
Closed Thread

Bookmarks

Tags
solaris date

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0