新人第一次接触shell下面的内容该如何转成windows的批处理?
①echo `date +'%Y-%m-%d %H:%M:%S'` "[$level] ($0: pid=$$) $@" 1>&2
② com_log_info "DBファンクション開始 $1"
$ORACLE_HOME/bin/sqlplus -S $ORACLE_USER/$ORACLE_PASS@$ORACLE_SID << _EOD_
whenever sqlerror exit 255
var ret number;
exec :ret := $1;
exit :ret;
_EOD_
ret=$?
mes="DBファンクション"
if [ $ret -eq 0 ]; then
com_log_info "$mes($1)正常終了"
elif [ $ret -le 9 ]; then
com_log_warn "$mes($1)警告終了"
else
com_log_error "$mes($1)異常終了"
fi
③for file in `ls $BASEDIR/lib`; do
CLASSPATH=$CLASSPATH:$BASEDIR/lib/$file
done
$JAVA_HOME/bin/java $JAVA_OPTS -cp $CLASSPATH \
jp.co.toshiba_sol.rs.dps.common.batch.BatchRunner $@
exit $?
[解决办法]
3_new
set "BASEDIR=C:\test"
for /f "delims=" %%a in ('dir /b "%BASEDIR%\lib"') do (
set "CLASSPATH=%CLASSPATH%;%BASEDIR%\lib\%%a"
)
%JAVA_HOME%\bin\java %JAVA_OPTS% -cp %CLASSPATH% jp.co.toshiba_sol.rs.dps.common.batch.BatchRunner
exit errorlevel
@echo off
for /f "tokens=2" %%a in ('tasklist /v ^
[解决办法]
findstr /c:"- %0"') do (
set "myPid=%%a"
)
echo %date:~0,10% %time:~0,8% "[%level%] (%0: pid=%myPid%) $@" 1>&2
set ORACLE_USER=USERNAME
set ORACLE_PASS=PASSWORD
set ORACLE_SID=DATABASENAME
set oraSql=%temp%\myOra.sql
>"%oraSql%" echo conn %ORACLE_USER%/%ORACLE_PASS%@%ORACLE_SID%
>>"%oraSql%" echo whenever sqlerror exit 255
>>"%oraSql%" echo var ret number;
>>"%oraSql%" echo exec :ret := $1;
>>"%oraSql%" echo exit :ret;
sqlplus /nolog @"%oraSql%"