批处理文件:读取输入,测试它们,将结果保存到txt?

时间:2014-12-20 22:44:21

标签: windows batch-file

我试图做的是:

  1. input.txt中
  2. test.bat的
  3. output.txt
  4. @echo off
    
    setlocal
    
    set "SECRET=for /f "delims=" %%L in (input.txt)"  // reads text line by line //
    
    set "URL=curl --data-binary '' "http:localhost:port/page?requestType=SECRET=" // a line from input.txt will be set after SECRET= to test then move to another line
    
         

    等..//

    set "LOG=C:\output.txt" // save results
    
    >"%LOG%"
    

    我正在尝试做这项工作。请帮忙。感谢

1 个答案:

答案 0 :(得分:1)

试试这样:

@echo off

(for /f "delims=" %%a in (input.txt) do (
 echo curl --data-binary '' "http:localhost:port/page?requestType=SECRET=%%a
))>output.txt

编辑:

我认为您正在尝试这样做:

@echo off

setlocal enabledelayedexpansion

for /f "delims=" %%a in (input.txt) do (
 curl --data-binary '' "http:localhost:port/page?requestType=SECRET=%%a >output.txt
 for /f "tokens=6 delims=,:}" %%b in (output.txt) do (
        set "$Value3=%%b"
        echo !$Value3:~1,-1! >%%a_Result.txt
 )

这将为Secret_Result.txt

中的每个秘密保存value3