function call inside function is not working
Posted: 25 May 2014 09:04
Hi All,
I have the following batch script which calls the function inside another function.
-------------------
@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
goto :upServers
:getFullDomainPath
echo "Get full domain path"
goto :eof
:getProcesses
FOR /f "tokens=* delims=" %%I in ('wmic process get ProcessId^,CommandLine /format^:csv ^|findstr java^|findstr "domain.home"^|findstr /V /I /C:"findstr"') do (
FOR %%A in (%%I) do SET pid=%%A
echo PROCESS-PS: "process output printed here"
set COMMAND_LINE=%%I
echo Start of call
call :getFullDomainPath "!COMMAND_LINE!"
echo end of call
)
goto :eof
:upServers
CALL :getProcesses
---------------------------
At runtime the call to the :getFullDomainPath function is not happening for each of the process got from the output of the wmic command in for loop.
It somehow skipping the call :getFullDomainPath "!COMMAND_LINE!" for most of the iteration of the for loop.
Output
-------
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call executed
"Get full domain path"
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call executed
"Get full domain path"
end of call
Please help me with this...I need to execute this call for each iteration.
Thanks
SS
I have the following batch script which calls the function inside another function.
-------------------
@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
goto :upServers
:getFullDomainPath
echo "Get full domain path"
goto :eof
:getProcesses
FOR /f "tokens=* delims=" %%I in ('wmic process get ProcessId^,CommandLine /format^:csv ^|findstr java^|findstr "domain.home"^|findstr /V /I /C:"findstr"') do (
FOR %%A in (%%I) do SET pid=%%A
echo PROCESS-PS: "process output printed here"
set COMMAND_LINE=%%I
echo Start of call
call :getFullDomainPath "!COMMAND_LINE!"
echo end of call
)
goto :eof
:upServers
CALL :getProcesses
---------------------------
At runtime the call to the :getFullDomainPath function is not happening for each of the process got from the output of the wmic command in for loop.
It somehow skipping the call :getFullDomainPath "!COMMAND_LINE!" for most of the iteration of the for loop.
Output
-------
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call executed
"Get full domain path"
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call not executed
end of call
PROCESS-PS: "process output printed here"
Start of call ----------------------------------------->call executed
"Get full domain path"
end of call
Please help me with this...I need to execute this call for each iteration.
Thanks
SS