I have a very odd problem.

I'm using Fedora (with KDE), and I need ngrep for checking the data sent which is transfered through a specific port...

The strange part is that when my terminal (more precisely, Konsole, also I tried with another terminal apps - Yakuake, Guake, Terminator, etc) is on full screen on a bigger display (21" - 1920x1080) the ngrep output is looking like this:

T -> [AP]                                                                                                                                                                                            
GET /solr/col                                                                                                                                                                                                                                                                   
version=2 HTT                                                                                                                                                                                                                                                                   
gent: Solr[or
rClient] 1.0.
.Host: 127.0.
nection: Keep

..is somehow wrapped... I don't know exactly.

But if I keep the terminal on my laptop display (16" - 1600x900) the output is stretched on the whole terminal, which is the expected behaviour.

I searched (the whole google :) ) but I can't figure out where is the problem. I thought that might be something wrong with my displays configuration, but at home I have Kubuntu and one big display (21" - 1920x1080), and the strange behavior is the same. The only solution that I have is to keep the terminal not on full screen or to keep it in a smaller display. I think that this is something about terminal columns settings and I don't know exactly how to fix this.

Thanks in advance, Andrei

  • This may help: unix.stackexchange.com/questions/61584
    – Tom Zych
    Nov 25 '15 at 8:17
  • Thanks @TomZych, but seems that none of those solutions is working for me. If I'm running xterm directly, the problem is less odd. The wrapping is made less often so the lines are longer... Nov 25 '15 at 8:48

A few possibilities come to mind:

  • the program has (for whatever reason) detected that the screen is large and will reduce the width of columns for some obscure purpose of the developers
  • the program does not detect the screen size properly. As suggested by @tom-zych, this may happen if the program does not respond properly to a window-resizing event. The solutions offered in How to solve the issue that a Terminal screen is messed up? (usually after a resizing) are useful for cases other than the end program (ngrep), e.g., the resize program is mainly useful in cases where the terminal does not update its size as shown by stty -a.

In the first case, the manual page for ngrep(8) is of little help, since the only place it mentions column width is using an option:

-c cols
Ignore the detected terminal width and force the column width to the specified size.

and (repeating itself)

-c cols
Explicitly set the console width to cols. Note that this is console width, and not the full width of what ngrep prints out as payloads; depending on the output mode ngrep may print less than cols bytes per line (indentation).

but it does imply that ngrep is doing some formatting choice. Looking for insight here shows a commit:

allow column widths greater than 255.

that changes the type used to represent the number of columns from 8-bits to 32-bits. If your resized screen (using a small font) happened to be wider than 255 columns, ngrep would wrap around, giving you only 5 columns less than the excess over 255. From the example given, that seems that your terminal's width might be 255+5+15 = 270 characters.

You can check that using stty -a.

  • Thank you very much @ThomasDickey . When executing echo $COLUMNS the result is 273. The -c parameter resolves the issue: -c 260. The odd part is that if I'm exporting COLUMNS variable to a smaller value(eg. the same with the number which I give to ngrep command), the ngrep output is still wrapped. I'm gonna use the -c parameter. Thanks. Nov 25 '15 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.