Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I follow this post to check speed with netcat , but in his blog when he do ctrl-c ,he get data on sent received bytes.

In the post he ran :

time yes|nc -v -v -n 192.168.0.8 2222 >/dev/null
than after ctrl-c het get:
sent 87478272, rcvd 0
real 0m9.993s
user 0m2.075s
sys 0m0.939s

When I do ctrl-c , I don't get this data.

How can I get sent/received data by netcat?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

There are actually two implementations of netcat, the original implementation by *Hobbit* (called netcat-traditional in Debian/Ubuntu) and the OpenBSD implementation (called netcat-openbsd in Debian/Ubuntu). In Debian/Ubuntu the binaries are called nc.traditional and nc.openbsd respectively (and nc is a link to one of those via the alternatives system).

The blog post you reference is using nc.traditional which does show the sent/received bytes when exiting. You are probably using nc.openbsd which doesn't. Install the traditional implementation and call it explicitly.

% time yes | nc.traditional -vvn 127.0.0.1 10000 > /dev/null
(UNKNOWN) [127.0.0.1] 10000 (webmin) open
^C sent 99422208, rcvd 0
yes  1,06s user 0,09s system 38% cpu 3,003 total
share|improve this answer
add comment

You can use the Pipe Viewer (pv) utility to watch the visual progress of a stream. It can be modified to display the units of choice and is available on most distributions.

Example:

cat largefile | pv | netcat 192.168.10.1000 1234
share|improve this answer
    
I want to get it from netcat like in the posted blog ? –  Avihai Marchiano Oct 25 '12 at 14:34
    
Please show your command string. –  ewwhite Oct 25 '12 at 14:36
    
add this to the question, thank you. You can see it in the blog link. –  Avihai Marchiano Oct 25 '12 at 14:39
    
time yes|nc -v -v -n 192.168.0.8 2222 | pv | >/dev/null –  ewwhite Oct 25 '12 at 14:40
1  
The command should be like this - time yes| pv | nc -v -v -n 192.168.0.8 2222 >/dev/null –  Avihai Marchiano Oct 25 '12 at 16:37
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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