redirecting terminal output to local printer

redirecting terminal output to local printer

Post by Andy Gab » Mon, 07 Oct 1996 04:00:00



Unix Pine can print to generic printers attached to ansi terminals.

Pine uses escape sequences on ansi/vt100 terminals.  "<ESC>[5i"
directs all output sent to terminal to the printer, then "<ESC>[6i" to
return to normal.

I have tried to implement this in the following script:

#!/bin/sh
echo "\033[5i"        #redirect terminal to printer
cat somefile    #send file to printer
echo "\033[6i"        #should reset terminal

The first echo works fine.
The file is sent to printer
The second echo *does not reset terminal output but rather continues
to output to printer so the "[6i" is sent to printer.

Clearly there is something I do not understand. Maybe this cannot be
done with shell script.

Any insights appreciated.

Andy

--
   +---------------------------------+--------------------------------+

   | Department of Neurology         | FAX   - (916)452-2739          |
   | University of California, Davis |                                |
   +---------------------------------+--------------------------------+

 
 
 

redirecting terminal output to local printer

Post by Roger Espel Lli » Mon, 07 Oct 1996 04:00:00




>Unix Pine can print to generic printers attached to ansi terminals.

>Pine uses escape sequences on ansi/vt100 terminals.  "<ESC>[5i"
>directs all output sent to terminal to the printer, then "<ESC>[6i" to
>return to normal.

To the best of my knowledge, it is not Pine but rxvt which can be told
to send all terminal output to the printer, with the sequence "<ESC>[5i"
to begin and "<ESC>[4i" to end.

Quote:>I have tried to implement this in the following script:

>#!/bin/sh
>echo "\033[5i"    #redirect terminal to printer
>cat somefile        #send file to printer
>echo "\033[6i"    #should reset terminal

A full terminal reset is "<ESC>c" for ANSI/vt* terminals, but if you're
using rxvt to print your text, the second sequence should be "\033[4i"
to reset the printing only.

        -Roger
--

WWW page & PGP key: http://www.eleves.ens.fr:8080/home/espel/index.html

 
 
 

redirecting terminal output to local printer

Post by Andy Gab » Mon, 07 Oct 1996 04:00:00



Quote:>To the best of my knowledge, it is not Pine but rxvt which can be told
>to send all terminal output to the printer, with the sequence "<ESC>[5i"
>to begin and "<ESC>[4i" to end.
>A full terminal reset is "<ESC>c" for ANSI/vt* terminals, but if you're
>using rxvt to print your text, the second sequence should be "\033[4i"
>to reset the printing only.

Absolutely right.  The Pine documentation is wrong !!

Many thanks,

Andy

--
   +---------------------------------+--------------------------------+

   | Department of Neurology         | FAX   - (916)452-2739          |
   | University of California, Davis |                                |
   +---------------------------------+--------------------------------+

 
 
 

redirecting terminal output to local printer

Post by Andy Gab » Mon, 07 Oct 1996 04:00:00


Appreciate all the responses. For the record here is what appears to
work:

----begin script------
#!/bin/sh
#script to send file to local attached ANSI/VT* printers
#tp
#ajg 10.6.96
#
if [ "$#" -ne "0" ]; then
  for arg in $*
  do
    if [ -f $arg ]; then
      echo "\033[5i"          # redirect terminal to printer
      cat $arg;                 # send file
      echo "\014"             # formfeed
      echo "\033[4i"          # reset terminal
    else
      echo "File $arg not found..."
    fi
  done
else
  echo "Usage: $0 filename [filename...]"
fi
#-----end script--------

--
   +---------------------------------+--------------------------------+

   | Department of Neurology         | FAX   - (916)452-2739          |
   | University of California, Davis |                                |
   +---------------------------------+--------------------------------+

 
 
 

redirecting terminal output to local printer

Post by Don Re » Wed, 09 Oct 1996 04:00:00


In the beginning, or at least on 6 Oct 1996 13:31:33 GMT,  Andy Gabor

Quote:

>Unix Pine can print to generic printers attached to ansi terminals.

>Pine uses escape sequences on ansi/vt100 terminals.  "<ESC>[5i"
>directs all output sent to terminal to the printer, then "<ESC>[6i" to
>return to normal.

>I have tried to implement this in the following script:

>#!/bin/sh
>echo "\033[5i"  #redirect terminal to printer
>cat somefile    #send file to printer
>echo "\033[6i"  #should reset terminal

>The first echo works fine.
>The file is sent to printer
>The second echo *does not reset terminal output but rather continues
>to output to printer so the "[6i" is sent to printer.

Here's what I use (SysV)

MC4VAR=`tput mc4`
if [ -z "$MC4VAR" ]
then
echo "                ***************************************"
echo "                *                                     *"
echo "                * Your local print job failed         *"
echo "                * becasue your terminfo setting is    *"
echo "                * not correct. Please check your mc4  *"
echo "                * and mc5 settings then reprint       *"
echo "                *                                     *"
echo "                ***************************************"
echo
echo "                                          press <RET>\c"
read dummy
        exit 1
fi

HFILE=`echo "/tmp/H"$$`
TFILE=`echo "/tmp/T"$$`
tput mc5 > $HFILE
echo "\014" > $TFILE
tput mc4 >> $TFILE


do
        case "$I" in
                -c | -d* | -n* | -s ) ;;
                * ) cat -s $HFILE $I $TFILE;;
        esac
done

rm $HFILE $TFILE
exit 0

--


 Calcasieu Lumber Co.                    Austin TX
    will sysadmin for food ...

 
 
 

1. changing the default printer for my login so i can use printer local on X-terminal

i have a HP Deskjet 895Cxi hooked up to a HDS Viewstation connect to a
server running Open Desktop 3.2v5.0.5.  i have configured the printer
to work and i can print to it.  the problem is that i have to specify
my destination.  i would like to change my default printer fron the
server default to the one local to my X-Terminal.  can some one please
direct me to some documentation that will address this.

thank you

E

2. sound card config problem.

3. How to redirect input/output to local&remote display

4. laptop for linux and mswindows?

5. redirect terminal output to file during boot ?

6. Linux & NT on the same machine

7. Need to redirect the output of HP Openview opened map to a VNC terminal

8. E-mail: cleaning up MIME attachments

9. redirect terminal output

10. pseudo-terminal and redirecting certain output to a new xwindow help

11. Redirecting output to another terminal

12. pseudo-terminal and redirecting certain output to a new xwindow help (in c++)

13. Redirecting terminal output...