| Summary: | Netcat (nc(1)) manual mistake | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Documentation | Reporter: | Yasir M. Arsanukaev <yasir27> | ||||
| Component: | Books & Articles | Assignee: | Benedict Reuschling <bcr> | ||||
| Status: | Closed FIXED | ||||||
| Severity: | Affects Only Me | ||||||
| Priority: | Normal | ||||||
| Version: | Latest | ||||||
| Hardware: | Any | ||||||
| OS: | Any | ||||||
| Attachments: |
|
||||||
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. 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 I'm working on that. 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 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. 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 MFC is finished, PR closed. Thanks for sending us this issue. |
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). Fix: There should have been used printf(1) instead. Man should be corrected, namely, sed 's/echo -n/printf/' 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 <html> <head><title>400 Bad Request</title></head> <body bgcolor="white"> <center><h1>400 Bad Request</h1></center> <hr><center>nginx</center> </body> </html>