[comp.lang.postscript] PostScript from Unix tty

shiva@well.sf.ca.us (Kenneth Porter) (05/20/91)

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
 
If you're using telnet to talk to the terminal server, you may
need to check the manual page to see if it does anything
special with the eof character (CTRL-D under Unix).  This might
be the cause of your problem.
 
Ken (shiva@well.sf.ca.us)

chawley@sundiver.esd.sgi.com (Christopher J. Hawley) (05/22/91)

    In article <24889@well.sf.ca.us>, shiva@well.sf.ca.us (Kenneth Porter)
writes:

|> 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

I don't know if the last command is required, but it is polite.

|> Ken (shiva@well.sf.ca.us)
---
    Christopher J. Hawley / esper               chawley@sundiver.esd.sgi.com
    Silicon Graphics, Inc.    1L-945            phone:  415 / 335-1621
    Mountain View, CA   94039-7311  USA                 408 / 243-1042
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "Nicht nur wie schnell Sie fahren, sondern _wie_ Sie schnell fahren."

clewis@ferret.ocunix.on.ca (Chris Lewis) (05/23/91)

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!