Windows batch script to Shell script

Hi everyone,

I've below windows batch script which is used to filter the file contents line by line and assign the matched values to the variables in for loop.

for /F "tokens=1,3 delims=:[]" %%A in (%LOG_DIR%\PM_IS_workflow_status.log) do (
set "ATTR_NAME=%%A"

if /i "!ATTR_NAME!" EQU "Folder" (
set FLD_NAME=%%B
)
if /i "!ATTR_NAME!" EQU "Workflow" (
set WKF_NAME=%%B
)
if /i "!ATTR_NAME!" EQU "Workflow run status" (
set WKF_STAT=%%B
echo !WKF_STAT! | findstr /I /C:"terminat"
set ERR_CODE=!errorlevel!
if !ERR_CODE!==0 (
echo !FLD_NAME!,!WKF_NAME!,!WKF_STAT! >> %LOG_DIR%\PM_wkf_status.csv
set "EMAIL_FL=Y"
 )
)

I'm trying to write the same code in shell script but nt able to find the relevant functions in shell.Could anyone please help to convert the same code to shell script.It will be of great help

Regards,
Anil

Refer this page and give it a try. Let us know if you are stuck.

1 Like