我有一个批处理脚本将提交证书请求,它将在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
然后,它会取出文件的第一个数字和最后一个数字并将其回显出来。 例如,请批准从请求ID 900证书920
这是我已经试过:
for /f "tokens=2 delims=:" %%b in ('"C:\program Files\command.exe"'|find
"RequestId : ") do (
echo %%b >> RequestID.txt
)
感谢您的帮助。真的是一个很长的帖子,很多消化哈哈。 – Kaycee