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

serial printer hold open scripts with 'cat'


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'



Increase ad revenue 50-250% with Ezoic

Kerio Samepage


Have you tried Searching this site?

Support Rates

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





Legend has it that every new technology is first used for something related to sex or pornography. That seems to be the way of humankind. (Tim Berners-Lee)





This post tagged: