Wednesday, August 28, 2013

Retrieving Solaris and Sybase version information

Solaris

-bash-3.2$ cat /etc/release
                   Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC
  Copyright (c) 1983, 2011, Oracle and/or its affiliates. All rights reserved.
                            Assembled 23 August 2011


Sybase Replication Server

-bash-3.2$ isql -Uadminuser -Padminpassword -SReplicationHostName
1> admin version
2> go
 Version                                                                       
 -------------------------------------------------------------------------------------------------------
 Replication Server/15.7.1/EBF 21458 SP102 rs1571sp102/Sun_svr4/OS 5.8/1/OPT64/M
         on Jul 15 18:06:33 2013


Sybase Open Switch Server

-bash-3.2$ isql -UadminstratorUserName -Ppassword -SOpenSwitchServerHostname
Administrator access granted
1> rp_version
2> go
 Version                                                                       
 ----------------------------------------------------------------------------------------
 Sybase OpenSwitch/15.1/EBF19772 ESD#6/P/SPARC/Solaris 2.8/0/OPT/Wed Feb  1 21:0
         3:54 2012

(1 row affected)
(return status = 0)


Tuesday, August 20, 2013

sybase sql how to get a timestamp for a past date

This assumes your using the 'datetime' type in sql. The important part is where you use the dateadd funtion

This is for a timestamp two weeks ago.

select name, executiontime
from tasktable
where executiontime < dateadd(week,-2,getdate())
go

Of course you can play around with the dateadd parameters to get timestamps for whatever time you want.

solaris shell how to get a timestamp for an hour ago or yesterday

There are various ways to nearly get it right, but then you run into the problem of whats midnight minus one and your scripts dont make any sense any more. This gets round the problem.

For one hour ago:

-bash-3.00$ TZ=$TZ-2 date '+%D %T'
08/20/13 13:00:51
-bash-3.00$ date
Tue Aug 20 14:00:54 EEST 2013
-bash-3.00$

For 24 hours ago

 -bash-3.00$ TZ=$TZ+21 date '+%D %T'
08/19/13 13:52:48
-bash-3.00$ date
Tue Aug 20 13:53:01 EEST 2013
-bash-3.00$

It all depends on the timezone in which your server resides, so you might have to play around with the TZ value to get it correct for your part of the world