[CentOS] nc not working as advertised

Keith Keller kkeller at wombat.san-francisco.ca.us
Thu Mar 7 23:30:31 UTC 2013


On 2013-03-07, Robert Moskowitz <rgm at htt-consult.com> wrote:
>
> On 03/07/2013 05:06 PM, Paul Heinlein wrote:
>> On Thu, 7 Mar 2013, Robert Moskowitz wrote:
>>
>>> I can't get nc to do anything worthwhile. In fact I can't even get the
>>> examples in the manpage to work.  From either my C6 servers or my F17
>>> notebooks.  For example:
>>>
>>> echo -n "GET / HTTP/1.0\r\n\r\n" | nc medon.htt-consult.com 80
>>
>> You mean
>>
>>   echo -ne "GET ..."
>>
>> right?
>
> No.  I did a simple copy from the manpage.  check it out yourself. :(

The man page may be incorrect.  You need -e in order to get echo to
print out the line feeds properly:

$ echo -ne "GET / HTTP/1.0\n\n" 
GET / HTTP/1.0

$ echo -n "GET / HTTP/1.0\n\n" 
GET / HTTP/1.0\n\n$ 

(I left the $ prompt in the output, to show that there's really no line
feed.)

Did you also try the client/server example in the man page (which looks
correct to me)?

--keith

-- 
kkeller at wombat.san-francisco.ca.us





More information about the CentOS mailing list