Closed aekinskjaldi closed 2 years ago
Looks like it is working properly here for grabbing that version on CentOS 7 under either bash or sh(but both of those working the same is hardly surprising).
[root@elk0]0|/root>sh
sh-4.2# VER=$(ntpd --version 2>&1 | head -n 1)
sh-4.2# echo $VER
ntpd 4.2.6p5
sh-4.2# exit
[root@elk0]0|/root>bash
[root@elk0 ~]# VER=$(ntpd --version 2>&1 | head -n 1)
[root@elk0 ~]# echo $VER
ntpd 4.2.6p5
[root@elk0 ~]# ntpd --version > /dev/null
ntpd 4.2.6p5
[root@elk0 ~]#
Derp. Sorry. Disregard what I said. I see what you mean now.
Thanks. And aye, you are correct.
Tested and looks good. Thanks!
Made all POSIX happy and merged. Thanks!
ntpd --version
from Centos 7 repo gives output to stderr instead of stdout, and thus variable VER remains empty even if version is exactly as mentioned in condition, i.e. 4.2.6p5, and instead ofntpdc
command script tries to executentpq
Moreover,ntpdc
does not resolve localhost correctly and gives errorI rewrote condition this way to make it work