作者 主題: Batch轉換Shell請教  (閱讀 585 次)

0 會員 與 1 訪客 正在閱讀本文。

test121

  • 可愛的小學生
  • *
  • 文章數: 1
    • 檢視個人資料
Batch轉換Shell請教
« 於: 2020-05-25 19:47 »
下面該怎麼改成Shell寫法?
SET SYSDATE=%YEAR%%MONTH%%DAY%     

SET DATETIMEF=%HOUR%%MIN%%SECS% 

SET LOG_FILE=compare_1-1_%SYSDATE%_%DATETIMEF%.log 

set i=-1

if %ComputerName%==AAA set Parameter_file=..\parameter\edw002m_parameterD.txt

if %ComputerName%==BBB set Parameter_file=..\parameter\edw002m_parameterU.txt

if %ComputerName%==CCC set Parameter_file=..\parameter\edw002m_parameterP.txt

if %ComputerName%==DDD set Parameter_file=..\parameter\edw002m_parameterP.txt

 

echo %Parameter_file%

echo %data% %time% > %LOG_FILE%                   

echo %ComputerName% >> %LOG_FILE%           

echo %Parameter_file% >> %LOG_FILE%

 

for /f "delims=" %%a in ('more ^< %Parameter_file%') do (

        set/a i+=1 & for /f %%z in ('echo/%%i%%') do (

                if "%%z"=="0" set MSSQL_NAME=%%a

                if "%%z"=="1" set MSSQL_USER=%%a

                if "%%z"=="2" set MSSQL_PWD=%%a

                if "%%z"=="3" set EVOICE_SERVER=%%a

                )

)


if "%%z"=="0" set MSSQL_NAME=AAA

if "%%z"=="1" set MSSQL_NAME=BBB

if "%%z"=="2" set MSSQL_NAME=CCC


echo %MSSQL_NAME%

echo --------------- SP 0 execution begining %time% -------------- >> %LOG_FILE%

sqlcmd -S%MSSQL_NAME% -U%MSSQL_USER% -P%MSSQL_PWD% -icompare_exec0.sp>> %LOG_FILE%

echo --------------- SP 0 execution end %time% -------------- >> %LOG_FILE%


goto check

:end_check

goto COPY_EVOICE

:end_COPY_EVOICE

goto exit

:check

if exist D:\EDW\log\*.* goto end_check

echo %date% %time% file not exist >> %LOG_FILE%

goto exit

:COPY_EVOICE

:exit

move %LOG_FILE% ..\log\

exit