I want to get vsftpd version into shell variable. I can get it to console with ease:
# vsftpd -version
vsftpd: version 2.2.2
Also I can get a lot of other info into variable:
# i=`bash --version 2>&1 | head -n1`; echo "=$i=";
=GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)=
(please note output is between "=" signs).
This simple way does not work with vsftpd:
# i=`vsftpd -version 2>&1`; echo "=$i=";
vsftpd: version 2.2.2
==
Please note $i is "" here.
What am I doing wrong?
Best Answer
Interestingly enough, my
vsftpd
writes the versino string tostdin
. So you probably need to do a rather unusual redirection ofstdin
tostdout
:How to find this out: run it in
strace
(you'll need to do it as root) and check for the string. In my case the log ends like this:The first argument to
write()
is the file descriptor (0/1/2 stand for stdin/stdout/stderr respectively).