从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去掉。

你可能感兴趣的:(bash,oracle)