简体   繁体   English

使用Windows批处理文件读取文件内容并执行命令

[英]Reading file content using windows batch file and executing a command

It looks like duplicate question but it is not. 它看起来像重复的问题,但事实并非如此。

I have two files 我有两个档案

  • Users.txt - contains 5 user names Users.txt-包含5个用户名
  • Prg.bat - this program should read each line and execute an ldapsearch command. Prg.bat-此程序应读取每一行并执行ldapsearch命令。

I tried below commands but nothing worked. 我尝试了以下命令,但没有任何效果。

For /F "eol=*"%%G in ("c:\temp\users.txt") do @echo %%G

Am i missing something here. 我在这里想念什么吗?

My output should show user1, user2,user3 我的输出应显示user1,user2,user3

您引用路径,因此假定迭代位于文字字符串而非文件之上,只需删除它们:

For /F "eol=* "%%G in (c:\temp\users.txt) do @echo %%G

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

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