Reading long lines from TTY

Casper H.S. Dik dik at uva.UUCP
Fri Feb 3 23:58:26 AEST 1989


In article <3134 at uhccux.uhcc.hawaii.edu> david at uhccux.uhcc.hawaii.edu (David Lassner) writes:
>Any suggestions on using standard utilities to read VERY
>long lines from the TTY using Unix (Ultrix 2.2).  The
>intuitive:
>	%cat > filename
>and
>	%cp /dev/ttyxx filename
>both stop accepting characters after about 250 without a CR.
>
>Our user basically wants to do the equivalent of a TOPS-20
>	@copy tty: filename
>to upload text that does not contain line breaks.  Yes, we
>know about Kermit and other protocols, but they can't be
>used in this case.

Normally the terminal driver buffers all characters until it sees a
line terminator or special character (intr del, etc).
The buffer holds a maximum of 256 chars.

You can get around this. All you have to change is the terminal settings.
Put your tty in cbreak mode. This will cause each character typed
to be send to the reading process directly.

You can do this with:
		% stty cbreak
		% cat > file
		% stty -cbreak

But beware: If you use a shell that fiddles with the terminal settings this
won't work. (E.g. ksh, or csh with filec set)
So in csh do:
		% unset filec

Or use /bin/sh, to be on the save side.

>-- 
>David Lassner, University of Hawaii Computing Center, 808/948-7351
>INTERNET: david at uhccux.uhcc.hawaii.edu      BITNET: david at uhccux
>UUCP:     ...!ucsd!nosc!uhccux!david        PLATO:  david/p/hawaii


--cd
____________________________________________________________________________
Casper H.S. Dik
University of Amsterdam     |		      dik at uva.uucp
The Netherlands             |                 ...!uunet!mcvax!uva!dik



More information about the Comp.unix.questions mailing list