1

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 127.0.0.1:39167 -> 127.0.0.1:8983 [AP]                                                                                                                                                                                            
GET /solr/col                                                                                                                                                                                                                                                                   
lection1/sele                                                                                                                                                                                                                                                                   
ct?q=%28entit                                                                                                                                                                                                                                                                   
yType%3A61+AN                                                                                                                                                                                                                                                                   
D+owncCompany                                                                                                                                                                                                                                                                   
_b%3Atrue%29&                                                                                                                                                                                                                                                                   
fl=*%2C%5Bchi                                                                                                                                                                                                                                                                   
ldren%5D&star                                                                                                                                                                                                                                                                   
t=0&rows=10&s                                                                                                                                                                                                                                                                   
ort=entityId_                                                                                                                                                                                                                                                                   
s+asc%2Cid+as                                                                                                                                                                                                                                                                   
c&wt=javabin&                                                                                                                                                                                                                                                                   
version=2 HTT                                                                                                                                                                                                                                                                   
P/1.1..User-A
gent: Solr[or
g.apache.solr
.client.solrj
.impl.HttpSol
rClient] 1.0.
.Host: 127.0.
0.1:8983..Con
nection: Keep
-Alive....   

..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

2
  • 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
2

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.

1
  • 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.