From nobody@FreeBSD.org Sat Jan 2 15:04:14 2010 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BEB65106568B for ; Sat, 2 Jan 2010 15:04:14 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id AE7078FC12 for ; Sat, 2 Jan 2010 15:04:14 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o02F4Ewa016710 for ; Sat, 2 Jan 2010 15:04:14 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o02F4EAU016709; Sat, 2 Jan 2010 15:04:14 GMT (envelope-from nobody) Message-Id: <201001021504.o02F4EAU016709@www.freebsd.org> Date: Sat, 2 Jan 2010 15:04:14 GMT From: Yasir To: freebsd-gnats-submit@FreeBSD.org Subject: Netcat (nc(1)) manual mistake X-Send-Pr-Version: www-3.1 X-GNATS-Notify: >Number: 142243 >Category: docs >Synopsis: Netcat (nc(1)) manual mistake >Confidential: no >Severity: non-critical >Priority: low >Responsible: bcr >State: closed >Quarter: >Keywords: >Date-Required: >Class: doc-bug >Submitter-Id: current-users >Arrival-Date: Sat Jan 02 15:10:04 UTC 2010 >Closed-Date: Mon Aug 02 16:02:44 UTC 2010 >Last-Modified: Mon Aug 02 16:02:44 UTC 2010 >Originator: Yasir >Release: 7.1-RELEASE >Organization: >Environment: FreeBSD conductor.loc 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 14:37:25 UTC 2009 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: man 1 nc states in TALKING TO SERVERS section: [..] For example, to retrieve the home page of a web site: $ echo -n "GET / HTTP/1.0\r\n\r\n" | nc host.example.com 80 [..] But this kind of request often returns either nothing or something irrelevant, maybe due to a strong server implementation (e.g. meets RFCs). >How-To-Repeat: According to man one could do the following: $ echo "GET / HTTP/1.0\r\n\r\n" | nc example.com 80 But nothing is returned upon request. Another attempt which also fails: $ echo "HEAD / HTTP/1.0\r\n\r\n" | nc ya.ru 80 400 Bad Request

400 Bad Request


nginx
>Fix: There should have been used printf(1) instead. Man should be corrected, namely, sed 's/echo -n/printf/' >Release-Note: >Audit-Trail: From: Yasir Arsanukaev To: bug-followup@FreeBSD.org Cc: Subject: Re: docs/142243: Netcat (nc(1)) manual mistake Date: Sun, 3 Jan 2010 02:26:45 +1000 --00032555843a449031047c30f459 Content-Type: text/plain; charset=UTF-8 While echo in bash(1), sh(1) and csh(1) don't handle '\n' and '\r' properly, I've discovered echo works correctly in zsh(1). Patch is attached and can be applied this way: $ patch /usr/src/contrib/netcat/nc.1 < nc.1.diff The other way is to mention that example works only in zsh. --00032555843a449031047c30f459 Content-Type: application/octet-stream; name="nc.1.diff" Content-Disposition: attachment; filename="nc.1.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: file0 LS0tIG5jLjEJMjAwOC0xMS0yNSAxMjo1OToyOS4wMDAwMDAwMDAgKzEwMDAKKysrIG5jLjEubmV3 CTIwMTAtMDEtMDMgMDM6MTg6MzMuMDAwMDAwMDAwICsxMDAwCkBAIC0zMzEsNyArMzMxLDcgQEAK IGluIHJlc3BvbnNlIHRvIGNvbW1hbmRzIGlzc3VlZCBieSB0aGUgY2xpZW50LgogRm9yIGV4YW1w bGUsIHRvIHJldHJpZXZlIHRoZSBob21lIHBhZ2Ugb2YgYSB3ZWIgc2l0ZToKIC5CZCAtbGl0ZXJh bCAtb2Zmc2V0IGluZGVudAotJCBlY2hvIC1uICJHRVQgLyBIVFRQLzEuMFxlclxlblxlclxlbiIg fCBuYyBob3N0LmV4YW1wbGUuY29tIDgwCiskIHByaW50ZiAiR0VUIC8gSFRUUC8xLjBcZXJcZW5c ZXJcZW4iIHwgbmMgaG9zdC5leGFtcGxlLmNvbSA4MAogLkVkCiAuUHAKIE5vdGUgdGhhdCB0aGlz IGFsc28gZGlzcGxheXMgdGhlIGhlYWRlcnMgc2VudCBieSB0aGUgd2ViIHNlcnZlci4K --00032555843a449031047c30f459-- From: Doug Barton To: Yasir Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: docs/142243: Netcat (nc(1)) manual mistake Date: Sat, 02 Jan 2010 10:57:44 -0800 Yasir wrote: >> Fix: > There should have been used printf(1) instead. > Man should be corrected, namely, sed 's/echo -n/printf/' printf should always work, yes. In our sh and in bash, 'echo -e' will also work. hth, Doug -- Improve the effectiveness of your Internet presence with a domain name makeover! http://SupersetSolutions.com/ Computers are useless. They can only give you answers. -- Pablo Picasso Responsible-Changed-From-To: freebsd-doc->bcr Responsible-Changed-By: bcr Responsible-Changed-When: Sun Jul 25 13:42:57 UTC 2010 Responsible-Changed-Why: I'm working on that. http://www.freebsd.org/cgi/query-pr.cgi?pr=142243 From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: docs/142243: commit references a PR Date: Mon, 26 Jul 2010 18:33:47 +0000 (UTC) Author: bcr (doc committer) Date: Mon Jul 26 18:33:33 2010 New Revision: 210511 URL: http://svn.freebsd.org/changeset/base/210511 Log: Use "printf" instead of "echo -n" in an example because it should be more compatible for most shells that are out there. I contacted Philip Guenther at OpenBSD about this PR and he corrected the issue in their tree pretty fast. PR: docs/142243 Submitted by: Yasir (yasir27 at mail dot ru) Obtained from: OpenBSD Discussed with: delphij MFC after: 7 days Modified: head/contrib/netcat/nc.1 Modified: head/contrib/netcat/nc.1 ============================================================================== --- head/contrib/netcat/nc.1 Mon Jul 26 18:23:05 2010 (r210510) +++ head/contrib/netcat/nc.1 Mon Jul 26 18:33:33 2010 (r210511) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 15, 2010 +.Dd July 3, 2010 .Dt NC 1 .Os .Sh NAME @@ -340,7 +340,7 @@ when it might be necessary to verify wha in response to commands issued by the client. For example, to retrieve the home page of a web site: .Bd -literal -offset indent -$ echo -n "GET / HTTP/1.0\er\en\er\en" | nc host.example.com 80 +$ printf "GET / HTTP/1.0\er\en\er\en" | nc host.example.com 80 .Ed .Pp Note that this also displays the headers sent by the web server. _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" State-Changed-From-To: open->patched State-Changed-By: bcr State-Changed-When: Mon Jul 26 18:42:37 UTC 2010 State-Changed-Why: The fix based on this PR was incorporated into the OpenBSD tree. A commit to our HEAD has been made as a result. Until the MFC is through, I'll keep it in this state. http://www.freebsd.org/cgi/query-pr.cgi?pr=142243 From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: docs/142243: commit references a PR Date: Mon, 2 Aug 2010 15:55:18 +0000 (UTC) Author: bcr (doc committer) Date: Mon Aug 2 15:54:59 2010 New Revision: 210771 URL: http://svn.freebsd.org/changeset/base/210771 Log: MFC r210511: Use "printf" instead of "echo -n" in an example because it should be more compatible for most shells that are out there. I contacted Philip Guenther at OpenBSD about this PR and he corrected the issue in their tree pretty fast. PR: docs/142243 Submitted by: Yasir (yasir27 at mail dot ru) Obtained from: OpenBSD Discussed with: delphij Modified: stable/8/contrib/netcat/nc.1 Directory Properties: stable/8/contrib/netcat/ (props changed) Modified: stable/8/contrib/netcat/nc.1 ============================================================================== --- stable/8/contrib/netcat/nc.1 Mon Aug 2 15:33:16 2010 (r210770) +++ stable/8/contrib/netcat/nc.1 Mon Aug 2 15:54:59 2010 (r210771) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 15, 2010 +.Dd July 3, 2010 .Dt NC 1 .Os .Sh NAME @@ -340,7 +340,7 @@ when it might be necessary to verify wha in response to commands issued by the client. For example, to retrieve the home page of a web site: .Bd -literal -offset indent -$ echo -n "GET / HTTP/1.0\er\en\er\en" | nc host.example.com 80 +$ printf "GET / HTTP/1.0\er\en\er\en" | nc host.example.com 80 .Ed .Pp Note that this also displays the headers sent by the web server. _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" State-Changed-From-To: patched->closed State-Changed-By: bcr State-Changed-When: Mon Aug 2 16:01:08 UTC 2010 State-Changed-Why: MFC is finished, PR closed. Thanks for sending us this issue. http://www.freebsd.org/cgi/query-pr.cgi?pr=142243 >Unformatted: