date -d compatibility on Solaris


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting date -d compatibility on Solaris
# 1  
Old 04-02-2009
Data 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! Smilie

No, seriously, I would appreciate any help, whatsoever.
# 2  
Old 04-02-2009
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  
Old 04-02-2009
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  
Old 04-03-2009
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 :|.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Solaris Date format help please

I have list of dates in a file. Am reading each line and trying to format date, Can you please help me ? Sample file content: 02/22/16 USA is great country 02/21/16 USA future 02/23/16 who is he I want to read each line from above file and format date as below 2016-02-21 (i.e., using... (1 Reply)
Discussion started by: prince1987
1 Replies

2. Solaris

Solaris 11 compatibility/ucb install

Hi im a newbie to solaris. im given the task to install the compatibility/ucb component my environment is without internet connection. so when i ran the command: pkg install compatibility/ucb i get an error: Unable to contact valid package repository where can i find the download for this... (2 Replies)
Discussion started by: guy3145
2 Replies

3. Solaris

Retina display Macbook Pro and Solaris compatibility

Has anyone attempted to install Solaris 11 on a Macbook Pro with the new Retina display? I'm considering setting up a triple boot scenario with Windows 7, Mac OS X and Solaris 11. My goals are to learn the OS better and to gain daily exposure to it by running it as a desktop OS whenever possible. (11 Replies)
Discussion started by: DustinT
11 Replies

4. Hardware

Solaris HW compatibility list

I'm picking HW for my cheap Solaris server and am wondering if there is a decent list of HW compatible with the Solaris OS. The best I could find is this: OTN - Oracle Solaris 11 11/11: Hardware Compatibility List, but it surprises me that only a single motherboard is listed. I am searching... (1 Reply)
Discussion started by: RychnD
1 Replies

5. Solaris

Solaris 10 - HW compatibility

Sorry, if this isn't the right forum for this question. I would like to compile an executable with gcc/g++ under Solaris 10 on the following OLDER SPARC-machine and then run this executable on the NEW SPARC-machine (see description down in this post). I'm wondering if it would be possible or if... (4 Replies)
Discussion started by: sunfire
4 Replies

6. Solaris

Solaris 8 vs Solaris 10 compatibility issues !

Hello, I recently upgraded our system from Solaris 8 to 10. It seems couple of binaries crashed in the new server Solaris 10. Before digging too much on it , from theory it sounds like any binary that is built on Solaris 8 (using gmake) is supposed to be compatible with Solaris 10 , right ? ... (1 Reply)
Discussion started by: sudsa
1 Replies

7. Solaris

Clearcase compatibility with Solaris 10

Hi, Is Clearcase version 2002.05.00 is supported and compatible with Solaris10? Cheers, Ankur (1 Reply)
Discussion started by: sharmaankur85
1 Replies

8. Shell Programming and Scripting

Date in Solaris

Hi, I am working on date operations in perl. using following code, I am getting today date as per my required format. my $date1 = `date '+%m/%d/%Y'`; can I find day+1 date. (ie. If today is 12/01/2009 then I want to edit above code t find 12/02/2009) ---------- Post updated... (3 Replies)
Discussion started by: gentleDean
3 Replies

9. BSD

FreeBSD compatibility with Solaris UFS filesystem?

Hi, I'm new to BSD and would like to create a dual-boot between Solaris Express Community Edition and FreeBSD. I would just like to know if the Solaris UFS file system can be written to by BSD? I know that BSD uses UFS2, but I'm hoping that it is backwards compatible with UFS1 provided that... (0 Replies)
Discussion started by: Johnny SSH
0 Replies
Login or Register to Ask a Question