【发布时间】:2017-05-26 13:41:53
【问题描述】:
我有一个将提交证书请求的批处理脚本,它将在 CMD 中返回多个 RequestId。我希望批处理文件提取所有数字并将其与名为 RequestID 的文件名逐行存储在一个文件中。
这是执行脚本后命令行的输出
C:\OpenSSL\bin>RequestCert.bat
Generating a 2048 bit RSA private key
...................................................................+++
...........+++
writing new private key to 'xxxx'
-----
No value provided for Subject Attribute ST, skipped
RequestId: 1892
RequestId: "1892"
Certificate request is pending: Taken Under Submission (0)
Generating certificate request and key for xxxx
ECHO is off.
------------------------------------------------------------------------
Generating a 2048 bit RSA private key
........+++
...........................................................................
..........+++
writing new private key to 'xxxx'
-----
No value provided for Subject Attribute ST, skipped
RequestId: 1893
RequestId: "1893"
Certificate request is pending: Taken Under Submission (0)
Generating certificate request and key for xxxx
------------------------------------------------------------------------
Please approve the certificates before pressing enter.
Please approve the certificates before pressing enter.
Please approve the certificates before pressing enter.
Press any key to continue . . .
所以代码应该提取出RequestId后面的数字:
RequestId: 1892
RequestId: 1893
文件应该有:
1892
1893
然后它将获取文件的第一个数字和最后一个数字并将其回显。 例如,请批准从 Request ID 900 到 920 的证书。
这是我尝试过的:
for /f "tokens=2 delims=:" %%b in ('"C:\program Files\command.exe"'|find
"RequestId : ") do (
echo %%b >> RequestID.txt
)
【问题讨论】:
标签: batch-file