🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #6085

Re: PostScript from Unix tty

#6085
From: Chris Lewis
Date: Wed, 22 May 1991 23:18
59 lines
3349 bytes
In article <1991May21.224701.1144@odin.corp.sgi.com> chawley@sundiver.esd.sgi.com writes:
>    In article <24889@well.sf.ca.us>, shiva@well.sf.ca.us (Kenneth Porter)
>|> You should be able to send any character (including CTRL-D, the
>|> PostScript EOF) through a Unix tty if you first open it in raw
>|> mode. You can use stty together with cat to put the port in raw
>|> mode and send characters:
>|>  
>|> (stty -raw; cat foo.ps) > /dev/ttyxx
>         ^----  you mean "raw" (no dash), didn't you?

>    The above example will probably not work if you're running under System V
>or V7 UNIX or derivatives of same, due to a difference of convention for the
> stty(1)  command.  On such systems,  stty  uses __standard input__ to access
>the tty, and sends output (if any) to standard output; contrast this with BSD
> stty(1bsd) , which accesses the tty via standard output and sends its output
>to standard error.

>    Thus, to achieve the intended effect under System V and friends, you
>would want to do something like this:

>		(stty raw; cat foo.ps; stty -raw) </dev/ttyxx >/dev/ttyxx

System V doesn't have raw (or at least, most don't).

This is better:
	
	(stty -opost cs8 <&1; cat foo.ps) > /dev/ttyxx

(The cs8 enables 8-bit transmission, and isn't strictly necessary.
The <&1 mechanism is a little more concise way of getting stdin
to be the desired port.  -opost turns off ALL output translations, but
doesn't inhibit buffering)

The second stty isn't necessary unless the port is being held open by
something else - ie: you are logged in on that port.  If nothing is
(already) holding the port open, each time you run this you get a
set of default settings, then they're overridden by the stty.  The
overrides evaporate when you close the port.  The next open will
get the defaults again.  So, you're advised to set the other desired
stty parameters too.  Eg: baud, x-on/x-off etc:

	(stty 9600 -opost xon cs8 < &1; cat foo.ps) > /dev/ttyxx

Setting all of the parameters you need is most advisable on all versions
of UNIX if the port isn't already open.

[See System V lp spooler interface files for further examples]

Further, even on non-System V systems, "raw" is usually the wrong thing to do.
You lose x-on/x-off for one thing.  What you really want to do is explicitly
turn off all of the output translations, eg: "tabs", all newline/carriage
return translations, delays etc.  Not only do you get to keep x-on/x-off
for flow control, but you also greatly reduce the CPU overhead because
your output is still buffered.  Or, use CBREAK mode if you have to.
-- 
Chris Lewis, Phone: (613) 832-0541, Domain: clewis@ferret.ocunix.on.ca
UUCP: ...!cunews!latour!ecicrl!clewis; Ferret Mailing List:
ferret-request@eci386; Psroff (not Adobe Transcript) enquiries:
psroff-request@eci386 or Canada 416-832-0541.  Psroff 3.0 in c.s.u soon!
Technical Details
Message-ID: <1532@ecicrl.ocunix.on.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews2!cunews!micor!latour!ecicrl!clewis
References: <24889@well.sf.ca.us> <1991May21.224701.1144@odin.corp.sgi.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews2!cunews!micor!latour!ecicrl!clewis
From: clewis@ferret.ocunix.on.ca (Chris Lewis)
Newsgroups: comp.lang.postscript
Subject: Re: PostScript from Unix tty
Keywords: bsd sys5
Message-ID: <1532@ecicrl.ocunix.on.ca>
Date: 22 May 91 23:18:44 GMT
References: <24889@well.sf.ca.us> <1991May21.224701.1144@odin.corp.sgi.com>
Distribution: comp
Organization: Elegant Communications Inc., Ottawa, Canada
Lines: 59