redis 命令行連接去除warning提示


[root@localhost monitor]# echo "config get *" | redis-cli -a 123456a? 
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) "123456a?"
  5) "masterauth"

返回結果有Warning:,影響取值

參考鏈接
https://blog.csdn.net/weixin_34253126/article/details/92384670

結果如下

[root@localhost monitor]# echo "config get *" | redis-cli -a 123456a? 2>/dev//null 
  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) "123456a?"

原因是

warning 這串輸出並不是普通輸出,shell的標准輸出包含兩種,1(標准輸出)2(標准錯誤)我們的命令,即包含1也包含2,2即是我們想要去除的提示。

解決辦法將標准錯誤去除即可,如圖,加了2>/dev/null,將標准錯誤丟棄即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM