簡體   English   中英

Windows批處理讀取文件並運行命令

[英]windows batch read file and run command

我需要Windows批處理腳本的幫助。

我想讓批處理文件讀取文本文件nodes.txt中的主機名列表,然后為nodes.txt找到的每個主機名運行以下命令

這是要運行的命令

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 

-host腳本之后應放置主機名,例如

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

我試過了

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分配文件中找到的每個值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM