Reputation: 1
I would like to start off by thanking any contributors for their help. I am a beginner when it comes to creating batch files so I hope ill be providing enough information needed to answer my question.
I have a program called storagetool.exe that is expecting three variables; server, region, and prodid.
The number of servers is known and value is static.
The number of regions is known and value is static.
The number of prodids may not be known. Yesterday I had 4 prodids to check, today I have over 100.
So in the command terminal i would type 'storagetool.exe server1 9 9999' then I would receive output which I pipe into a text file called productlog.txt
----------Productlist.bat file-------------------------------
@(
StorageTool.exe server1 14 000123
echo _________________________________________________________________
) > productlog.txt
---------End of Productlist.bat------------------------------------------------
What I would like to do is have a textfile that has all the prodids that I am testing and have the batchfile pull from it. I would still like the output of the file to have the long line to separate the output from each prodid to help me read it.
the end result would be
---------prodid.txt-----------------------------------
00001
00002
00003
ext..
----------end of prodit.txt-----------------
output of the batchfile would look like;
(output of storagetool.exe server1 14 0001)
echo ______________________________
(output of storagetool.exe server1 14 00002)
echo ______________________________
(output of storagetool.exe server1 14 00003)
echo ______________________________
ext... piped into a textfile Prodlog.txt
Thank you for your help, it is greatly appreciated.
Upvotes: 0
Views: 66
Reputation: 70923
@echo off
(for /f "delims=" %%a in (prodid.txt) do (
echo --------------------------------
StorageTool.exe server1 14 %%a
)) > productlog.txt
For each line in the file, retrieve the line, store its data in the for
replaceable parameter %%a
and execute (for each line) the code in the do
clause.
All the output is redirected to log file
Upvotes: 1