从shell里面取得oracle系统时间

 在shell里面通过调用sqlplus取得oracle系统时间并返回shell的一种方法

#!/bin/sh

today=`sqlplus  -l -s ${LOGON} << EndOfSQL
          whenever sqlerror exit 1 ROLLBACK
           set heading off
           select to_char( sysdate, 'yyyymmdd' ) from dual;
           exit 0
EndOfSQL`
 
today=`echo $today | sed s/\n//`

从sqlplus取得的值不知为何总带一个换行符,所以通过sed去掉。

猜你喜欢

转载自jak47.iteye.com/blog/2170332