Create and use bat files that set and use environment variables, but environment variables are null
@echo off
setlocal
set "inputIpList=%~dp0IP_list.txt"
cd "Program Files7-Zip"
for /f %%a in (%inputIpList%) do (
echo "Processing entry: %%a"
set a1=%%a
echo %a1%
timeout /t 5
"Program Files7-Zip7z.exe" x -so "%~dp0monthly%a1%var-log-files.tgz" | 7z.exe x -aoa -si -ttar -o%~dp0monthly%a1%
for /l %%b in (9 -1 0) do (
echo %%b
set "b1=%%b"
echo "Extracting messages.%%b.gz"
"Program Files7-Zip7z.exe" x -so %~dp0monthly%a1%messages.%b1%.gz >> %~dp0monthly%a1%messages-merged.txt
)
type %~dp0monthly%a1%varlogmessages >> %~dp0%a1%messages-merged.txt
)
endlocal
pause
“%~dp0monthly%a1%var-log-files.tgz” is output as
".monthly\var-log-files.tgz"
Why is this happening?
Is it the way to run the next line before the previous command line is completed?
I’ve added a timeout command
set a1=%%a is change
set “a1=%%a”
New contributor
taemin kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.