Not able to grep xrdp version line by running below command on ubuntu 14.04

$ sudo xrdp -v | grep -i "version"

Output : Blank

$ sudo xrdp -v 

Output :

logging configuration:
    LogFile:       /var/log/xrdp.log
    LogLevel:      4
    EnableSyslog:  1
    SyslogLevel:   4

xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2004-2014
See http://www.xrdp.org for more information.
Version 0.9.0

Where as when try with other program like below perl command

$ sudo perl -V | grep "version"

Output :

Summary of my perl5 (revision 5 version 18 subversion 2) configuration:

How to get version 0.9.0 as output of command !


1 Answer 1


xrdp writes to 1, that is stdout as shown by strace but it looks that it buffers its output for some reasons. Try this:

$ unbuffer xrdp -v | grep Version
Version 0.9.4

Alternatively you can use stdbuf:

$ stdbuf  -o0  xrdp -v | grep Version
Version 0.9.4
  • Ok this works, but for that i have to install unbuffer program & its packages. Installing on 40 to 50 servers machine would make it difficult. Any other way !!! Mar 10, 2018 at 12:23
  • You might have more luck with stdbuf, it's a part of GNU coreutils. Mar 10, 2018 at 12:25
  • 3
    Interestingly, I found the root cause of this behavior. In common/os_calls.c they use _exit() instead of exit() and as man _exit says: Open stdio(3) streams are not flushed. On the other hand, _exit() does close open file descriptors, and this may cause an unknown delay, waiting for pending output to finish. If the delay is undesired, it may be useful to call functions like tcflush(3) before calling _exit(). Whether any pending I/O is canceled, and which pending I/O may be canceled upon _exit(), is implementation-dependent.. Mar 10, 2018 at 12:45
  • Changing _exit() to exit() makes it possible to grep -v output without unbuffer. Mar 10, 2018 at 12:45

You must log in to answer this question.

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