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?

2 Answers 2


Interestingly enough, my vsftpd writes the versino string to stdin. So you probably need to do a rather unusual redirection of stdin to stdout:

i=`/usr/sbin/vsftpd -version 0>&1`

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:

$ strace /usr/sbin/vsftpd -version
brk(0)                                  = 0x7f835332d000
brk(0x7f835334e000)                     = 0x7f835334e000
write(0, "vsftpd: version 3.0.2\n", 22) = 22
exit_group(0)                           = ?
+++ exited with 0 +++

The first argument to write() is the file descriptor (0/1/2 stand for stdin/stdout/stderr respectively).


The command vsftpd -v uses stdin so you can't grab the output in the normal way.

I usually just grab the response from the FTP port. I only allow FTP locally anyway.

echo "bye" | nc localhost 21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .