win007
初级用户
积分 45
发帖 44
注册 2008-11-22
状态 离线
|
『第
46 楼』:
@echo off
set SrcFile=D:\a.txt
for /f "skip=5 tokens=1-2 delims= " %%a in ('dir /tw "%SrcFile%"') do (
set "FileDay=%%a %%b"
goto :compare
)
:compare
REM set "FileDay=2008/11/25 20:57"
call :DateToMins %FileDay:~0,4% %FileDay:~5,2% %FileDay:~8,2% %FileDay:~11,2% %FileDay:~14,3% mFileDay
echo FileDay: %FileDay:~0,4% %FileDay:~5,2% %FileDay:~8,2% %FileDay:~11,2% %FileDay:~14,3% mFileDay
echo FileDay2Minutes: %mFileDay%
REM set "mydate=星期二 2008/11/25 15:53:54.40"
call :DateToMins %date:~4,4% %date:~9,2% %date:~12,2% %time:~0,2% %time:~3,2% mToday
echo Today: %date:~4,4% %date:~9,2% %date:~12,2% %time:~0,2% %time:~3,2% mToday
echo Today2Minutes: %mToday%
set /a mMinus=mToday-mFileDay
echo Minus: %mMinus%
if %mMinus% gtr 5 (
goto :Oracle down
) else (
goto :Oracle running
)
pause
goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:DateToMins %yy% %mm% %dd% %hh% %mm% result
::
:: By: Ritchie Lawrence, updated 2003-04-03. Version 1.1
::
:: Func: Returns the number of elapsed minutes since 1970-01-01 00:00
:: for a given date. For NT4/2K/XP/2003
::
:: Args: %1 years to convert, 2 or 4 digit (by val)
:: %2 months to convert, 1/01 to 12, leading zero ok (by val)
:: %3 days to convert, 1/01 to 31, leading zero ok (by val)
:: %4 hours to convert, 1/01 to 12 for 12hr times (minutes must be
:: suffixed by 'a' or 'p', 0/00 to 23 for 24hr clock (by val)
:: %5 mins to convert, 00-59 only, suffixed by a/p if 12hr (by val)
:: %6 var to receive number of elapsed minutes (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS
set yy=%1&set mm=%2&set dd=%3&set hh=%4&set nn=%5
if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
if 1%hh% LSS 20 set hh=0%hh%
if {%nn:~2,1%} EQU {p} if "%hh%" NEQ "12" set hh=1%hh%&set/a hh-=88
if {%nn:~2,1%} EQU {a} if "%hh%" EQU "12" set hh=00
if {%nn:~2,1%} GEQ {a} set nn=%nn:~0,2%
set /a hh=100%hh%%%100,nn=100%nn%%%100,j=j*1440+hh*60+nn
endlocal&set %6=%j%&goto :EOF
:Oracle down
set oraName=cim
set oraPass=cim
set oraDB=cim10t
set oraSql=%temp%\myOra1.sql
start sqlplus /nolog @"%oraSql%"
>"%oraSql%" echo conn %oraName%/%oraPass%@%oraDB%
>"%oraSql%" echo insert into MSG_TBL_SENDREQ t
>"%oraSql%" echo values ('PROMIS Adapter','','EMAIL','CY_PJHUANG','','PROMIS Adapter has been down','','','NEW','','','','','','','','','','','','','','','');
exit
:Oracle running
set oraName=cim
set oraPass=cim
set oraDB=cim10t
set oraSql=%temp%\myOra2.sql
start sqlplus /nolog @"%oraSql%"
>"%oraSql%" echo conn %oraName%/%oraPass%@%oraDB%
>"%oraSql%" echo insert into MSG_TBL_SENDREQ t
>"%oraSql%" echo values ('PROMISAdapter','','EMAIL','CY_PJHUANG','','PROMIS Adapter is running','','','NEW','','','','','','','','','','','','','','','');
exit
测试结果
SP2-0734:unknowen command beginning "er','','EM..." - rest of line ignored.
|
|