简体   繁体   English

Windows批处理读取文件并运行命令

[英]windows batch read file and run command

I need some help with windows batch script. 我需要Windows批处理脚本的帮助。

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 我想让批处理文件读取文本文件nodes.txt中的主机名列表,然后为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 -host脚本之后应放置主机名,例如

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. 将依次为%%i分配文件中找到的每个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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