简体   繁体   中英

windows batch read file and run command

I need some help with windows batch script.

I have a list of hostnames in a text file nodes.txt that I want batch file to read then run following commands for each hostname found in nodes.txt

Here are the commands to run

ovdeploy -upload -file "C:\Users\AG\scopemsgs" -targetdir "c:\temp" -host

ovdeploy -cmd "move c:\temp\scopemsgs 'C:\Program Files\HP\HP BTO Software\msg\C\'" -host

ovdeploy -cmd "ovpacmd start" -host

ovdeploy -cmd "perfstat -p" -host 

after -host script should put hostname for example

ovdeploy -upload -file "C:\Users\AG\scopemsgs" -targetdir "c:\temp" -host node123.com

I tried this

for /f %%i in (nodes.txt) do set node=%%i

ovdeploy -upload -file "C:\Users\AG\scopemsgs" -targetdir "c:\temp" -host node
for /f %%i in (nodes.txt) do (
 ovdeploy ... -host %%i
 ovdeploy ... -host %%i
 ovdeploy ... -host %%i
)

%%i will be assigned each value found in the file in turn.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM