运行实用程序时如何将控制台输出捕获到变量中,以便可以过滤文本?
示例:我试图在键入时捕获控制台输出,bitcoind
以便可以过滤掉rpcpassword并将其写入配置文件。
ubuntu@ip-172-31-3-49:~$ bitcoind
Error: To use bitcoind, you must set a rpcpassword in the configuration file:
/home/ubuntu/.bitcoin/bitcoin.conf
It is recommended you use the following random password:
rpcuser=bitcoinrpc
rpcpassword=Eb5WDgzKqt77U4LhvvfnYxaNvw2rpztSvM5XKsonXBWC
(you do not need to remember this password)
The username and password MUST NOT be the same.
If the file does not exist, create it with owner-readable-only file permissions.
It is also recommended to set alertnotify so you are notified of problems;
for example: alertnotify=echo %s | mail -s "Bitcoin Alert" [email protected]
将输出重定向到文件,例如
bitcoind >~/bitcoind_output.txt 2>&1
这会将输出放入您的主目录中名为bitcoind_output.txt的文件中
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句