我有一個批處理腳本將提交證書請求,它將在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