Would you accept a patch like this?
Posted on Fri 20 November 2009 by alex in geek
Wow, I actually found something that netcat can't do.
--- netcat-openbsd-1.89/netcat.c 2009-11-20 17:44:40.000000000 +0000 +++ netcat-openbsd-1.89.patched/netcat.c 2009-11-20 17:43:35.000000000 +0000 @@ -74,6 +74,7 @@ /* Command Line Options */ int Cflag = 0; /* CRLF line-ending */ +int cflag = 0; /* CR line-ending */ int dflag; /* detached, no stdin */ int iflag; /* Interval Flag */ int jflag; /* use jumbo frames if we can */ @@ -137,7 +138,7 @@ sv = NULL; while ((ch = getopt(argc, argv, - "46Ddhi:jklnP:p:rSs:tT:Uuvw:X:x:zC")) != -1) { + "46Ddhi:jklnP:p:rSs:tT:Uuvw:X:x:zCc")) != -1) { switch (ch) { case '4': family = AF_INET; @@ -230,6 +231,9 @@ case 'C': Cflag = 1; break; + case 'c': + cflag = 1; + break; default: usage(1); } @@ -748,6 +752,12 @@ if (atomicio(vwrite, nfd, "\r\n", 2) != 2) return; } + else if ((cflag) && (buf[n-1]=='\n')) { + if (atomicio(vwrite, nfd, buf, n-1) != (n-1)) + return; + if (atomicio(vwrite, nfd, "\r", 1) != 1) + return; + } else { if (atomicio(vwrite, nfd, buf, n) != n) return;
My dad has been experimenting with putting an old Flex system on the net. I was having trouble talking to it with netcat. Using Telnet was a little better but still failing. It turns out some very old systems have different line termination sequences. I can now play the original Colossal Cave :-)