APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > News Posts > serial printer hold open scripts with 'cat'
Printer Friendly Version




News Group Posts

serial printer hold open scripts with 'cat'

Main Index

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<

If this page was useful to you, please click to help others find it:  

Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

Comments?



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



ad

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-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. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

g_face.jpg

This post tagged:

       - Bela
       - SCO_OSR5




Unix/Linux Consultants

Skills Tests

Guest Post Here