同步获取nginx版本吗? [英] Get nginx version synchronously?

查看:87
本文介绍了同步获取nginx版本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试获取nginx版本时,发生了一些奇怪的事情.

Something weird is going on when I try to get the nginx version.

当我运行此命令时:

echo "[nginx]" $(nginx -v)

它打印

nginx version: nginx/1.4.6 (Ubuntu)
[nginx]

请注意,[nginx]位低于 nginx版本.

Notice the [nginx] bit is below the nginx version.

当我尝试使用Node OTOH,echo "[node]" $(node --version)时,我得到:

When I try with Node OTOH, echo "[node]" $(node --version), I get:

[node] v0.10.45

按预期顺序排列,因此回声不成问题.如何使nginx以正确的顺序打印?

Which is in the expected order, so it's not a problem with echo. How can I get nginx to print in the proper order?

不确定这是Bash/shell问题还是nginx程序的问题或什么.

Not sure if this is a Bash/shell issue or something funny with the nginx program or what.

推荐答案

谁知道为什么要做出决定,

Who knows why the decision was made, but nginx outputs to stderr. You can capture it by piping stderr to stdout:

echo "[nginx]" $(nginx -v 2>&1)

这篇关于同步获取nginx版本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆