*BSD News Article 70492


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!metro!metro!asstdc.scgt.oz.au!nsw.news.telstra.net!act.news.telstra.net!imci3!newsfeed.internetmci.com!usenet.eel.ufl.edu!arclight.uoregon.edu!dispatch.news.demon.net!demon!awfulhak.demon.co.uk!awfulhak.demon.co.uk!awfulhak.demon.co.uk!not-for-mail
From: brian@awfulhak.demon.co.uk (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: telnet wierdness... bug ?
Date: 7 Jun 1996 14:39:29 +0100
Organization: Coverform Ltd.
Lines: 43
Message-ID: <4p9beh$15t@anorak.coverform.lan>
X-NNTP-Posting-Host: awfulhak.demon.co.uk
X-Newsreader: TIN [version 1.2 PL2]

Verrrrrry strange !  I've written the following script called ppptimeout:

#! /bin/sh

netstat -na | fgrep .3000 >/dev/null || {
    echo ppp isn\'t running >&2
    exit
}

telnet localhost 3000 <<eof
set timeout $1
quit
eof


Nothing complicated.  I've got ppp -auto running with a timeout of 900
seconds.  At night, I connect to the internet, exchange news & mail and
disconnect.  Things are set up so that all cron has to do is ping (I've
hacked ppp to run /etc/ppp/ppp.etherup after connection), then timeout.

When I connect manually, I want a 900 second timeout.  I want auto-connects
to be only 30 seconds - hence the script.  This script (after adding a
couple of >/dev/null's) will do the job - I THOUGHT !

The result ?

telnet quits before reading & sending the 'set timeout' bit to socket
3000 - because it has already read the EOF.  This can be proven by
running telnet from a file equivalent to the above, except the file has
100000 linefeeds at the end - it works.

I would _almost_ assert that this is a bug.  I can't figure what's going
on except that stdin is buffered (512 bytes?) and telnet is doing a read
and figuring that it's seen EOF before actually processing the read buffer.

It's the same under 'sh' and 'bash'.  It's being run on a 2.1-RELEASE
machine.  Doing the telnet manually works (of course).

Any help or suggestions ?  TIA.

--
Brian <brian@awfulhak.demon.co.uk>
Don't _EVER_ lose your sense of humour....