APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

serial printer hold open scripts with 'cat'


© September 2005 (various authors)
From: Bela Lubkin <filbo@armory.com>
Subject: Re: Sleep command quitting
Date: 16 Sep 2005 13:33:45 -0400
Message-ID: <200509161033.aa15294@deepthought.armory.com> 
References: <432a9c89.26582515@giganews.nildram.co.uk>
<200509151342.aa23956@deepthought.armory.com>
<IMwxny.At3@wjv.com>
<Xns96D35FF90B361rickpalen@69.28.186.121> Rick Palen wrote: > Another way to do it (and it might even be older than '89, I can't > remember!) is to use a process like cat to keep the ports open. > > (stty ixon ixoff; cat >/dev/null ) </dev/ttya1 & > > We always put these in /etc/rc.d/8/userdef. If a support site > called with garbage on their printers, we always told them that > their cat died :) > > Bela's way with exec sleep 2000000000 is better but I just give > this for some historical context.

Actually I'd say your way is better.  Any length of `sleep` could
eventually time out.  Your `cat` has a different termination condition
-- receiving EOF on the tty.  Which is highly unlikely if there's
actually a printer attached to it.

It would be even better if there was an input source which the kernel
guaranteed to allow you to open, but which never produced any input.
Similar to /dev/null, but it should never return from read() instead of
always returning EOF.

But for this purpose, one of the printer ports would suffice.

One reason the `cat` might be better is that you can lard it with extra
arguments which will show up in `ps -ef`:

  exec </dev/ttya1 3</dev/ttya2 4</dev/ttya3
  stty 9600 ixon ixoff -ixany  < /dev/ttya1
  stty 4800 ixon ixoff -ixany  < /dev/ttya2
  stty 19200 ixon ixoff -ixany < /dev/ttya3
  exec cat - Holdopen script for ttya1, a2, a3

Now I'm using fd 0 (stdin) for the first printer port; shell syntax lets
us use that plus fds 3-9, so now we can do 8 per script.  (We could
probably also use fds 1 & 2, but it's safer not to.)



>Bela<
 
 
 
 
 
 
 
 



 

Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> serial printer hold open scripts with 'cat'


Inexpensive and informative Apple related e-books:

Take Control of Pages

Photos for Mac: A Take Control Crash Course

Are Your Bits Flipped?

Take Control of Automating Your Mac

Take Control of Apple Mail, Third Edition





Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





Educate the children and it won't be necessary to punish the men. (Pythagoras)




Linux posts

Troubleshooting posts


This post tagged:

Bela

SCO_OSR5

Serial



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode