Newsgroups: comp.unix.shell, comp.sys.sun.misc, comp.sys.sun.admin, comp.protocols.tcp-ip Followup-To: comp.sys.sun.admin From: hoey@AIC.NRL.Navy.Mil (Dan Hoey) Date: 4 Jun 92 22:11:43 GMT Subject: Unix shell TCP tools and /usr/etc/mconnect bug I occasionally write simple TCP clients as a shell script. The only tool I really need for the job is a filter that will connect the standard input and output to the streams of a TCP connection. Once upon a time I used telnet as the filter, but that had a problem: When the connection dropped, you would lose the end of the output--sometimes all the way back to the beginning. So I was happy to see mconnect(8) in the Sun distribution (did Sun write it, or is from BSD?) because it does exactly the right thing for me--almost. It has three problems, and two of them are minor. The third, however, is a fairly severe bug, and I would like suggestions for solving it. Problem 1: Mconnect does not translate NETASCII back to ASCII, so you get carriage returns (^M) in the output. I pipe the output through tr -d '\015' and that solves the problem. It would be faster, though, if mconnect did the translation. Also, I'm a little concerned that mconnect may not be inserting carriage returns on input, though I haven't run into problems with that yet. Problem 2: Mconnect prints connecting to host nic.ddn.mil (192.112.36.5), port 101 connection open at the beginning of the output. But most tcp services put out some sort of initial greeting that I have to ignore anyway, so ignoring two more lines is no problem. Still, this stuff should be on stderr. Problem 3: Mconnect SOMETIMES inserts connecting to host nic.ddn.mil (192.112.36.5), port 101 connection open at some random place in the output. It is apparently timing dependent, and I have no source to find out where it's coming from, and I really don't want to have to delete those lines when they could be valid output. For instance, the command echo ALL-MIL | /usr/etc/mconnect -p 101 nic.ddn.mil | grep -n connect gives me output like 1:connecting to host nic.ddn.mil (192.112.36.5), port 101 2:connection open 1436:connecting to host nic.ddn.mil (192.112.36.5), port 101 1437:connection open where the second set of line numbers occur somewhere between 1000 and 5000. Has anyone fixed the problem 3 bug? Is there a publicly available version of mconnect or equivalent? So far I've found "tcpcon" in Simtel20's PD6: directory, but that doesn't have the code to wait for the output to drain. Please mail me your suggestions, and I'll report any solutions that come in. Dan Hoey Hoey@AIC.NRL.Navy.Mil