Subject: Request for information on pine

From: Jonnan West <[email-masked]>
Date: Thu, 16 Oct 1997 18:46:14 -0500 (EST)

Pardon me, but Pine has a feature I'd like to be able to utilize
outside of pine itself, and was curious whether or not someone could show
me any method of doing so.
	The Pine print function uses an option referred to as attached to
ansi which allows me to telnet to my unix account, and pine will print an
e-mail message at my local terminal printer, wherever that may be.
	While I have long since worked out a work-around procedure
allowing me to print off something from my account, it involves switching
programs around and is a bit of a pain. However, if someone can explain to
me exactly how pine does what it does (Or a script? If possible?), then it
would simplify things considerably for me. 
	Note for reference - Pine has a message saying how to post to this
list. It did not have (Or, more precisely, I did not find) how to
subscribe to this list. With apologies, I would therefore prefer a direct
response to my student account (Repeated below, in case the remailer
strips the headers off this) 
	Thank you, and enjoy your day.
							Jonnan West
							[email-masked]

 - - - This Signature brought to you by WESTECH International, devising
incomplete solutions for impossible problems for nearly thirty years ! ! !
	See yet another useless WESTECH (TM) product at
             http://php.iupui.edu/~jewest/catalog.html

---

From: Richard Gering <[email-masked]>
Date: Fri, 17 Oct 1997 12:15:13 +0100 (WET)

> would simplify things considerably for me. 

Well, I've added a shell script for you to take a look at. This thing was
originally built to run from a specific software suite, so some of the
options may look a bit strange. Simply avoid them :-)

The script requires the AT&T/USG/V9 style echo command implementation,
using the backslash options (much like C's printf() function).

(bash users: make an alias from echo to "builtin echo -e" or, even better, 
 recompile bash with DEFAULT_ECHO_TO_USG enabled).

Hope this script accomplishes what you're looking for.

> strips the headers off this) 

Sent both ways. As for subscribing to this list:

  Subscription address:  [email-masked]

  Command to subscribe:  SUBSCRIBE listname [FOR alt-email-addr] Your Name

  Command to unsubscribe:  SIGNOFF listname [FOR alt-email-addr]

  Further information about listproc can be obtained by sending a
  message to [email-masked] with a blank subject and a body
  consisting of the single word "HELP".

Kind regards,

- Richard Gering.

-- 
+-----------------------------------------------------------------------------+
| Richard Gering ([email-masked]) |         UNIX: when you're ready         |
| Computer Industries International |         for an operating system         |
+-----------------------------------------------------------------------------+
:
#
# lpf_term V2.3:	Print files to a terminal slave printer.
#
# Modified  10/01/97:	Added support for vt220 with incomplete terminfo.
#	    rgering
#
# Modified  07/01/97:	Added support for 4320 with incorrect terminfo.
#	    rgering
#
# Modified  10/27/93:	When printing from stdin, don't print until stdin is
#	    rgering	closed (accomplished through a tmp_file). Done to
#			prevent screen and printer output getting mixed up.
#
# Modified  08/26/93:	Added options -prefix and -postfix to allow characters
#	    rgering	to be sent to the printer just before and right after
#			the text was printed (resulted from the automatic-
#			-printer-switchbox problem at the K.I.T.).
#			Added the -addcr option to automatically prepend a
#			<CR> to each <LF> for MS-DOS based printers.
#			Also added support for printing multiple files.
#
# Modified  06/22/93:	Added -control <semaphore_file> to accommodate for
#	    rgering	Kennys (4.1a+) based auxiliary printing from Progress.
#
# (C) 1993-1997 Richard Gering ([email-masked]). GNU Licensed et all.
#

prg=`basename $0`
error=false
addcr=false
tmp_file=/tmp/lpf.$$
files=""
prefix=""
postfix=""
control_file=""

# If specified, the control file is removed to indicate that the printing
# process has completed (used for programs from the Kennys suite).
# Note: rm -f silently accepts a missing filename.
#
cleanup()
{
	rc=$1
	echo "${printer_off}\c"
	rm -f ${control_file} ${tmp_file}
	trap 0 1 2 3 15
	exit $rc
}

# Test options
while [ $# -gt 0 ]
do
	case "$1" in
		-h)	error=true   # The help function
			;;
		-control  | \
		-c)	control_file="${2}"
			if [ -z "$control_file" ]
			then
				echo "${prg}: The ${1} option requires a filename to be removed after printing." >&2
				error=true
			else
				shift 1
			fi
			;;
		-addcr) \
			addcr=true
			;;
		-prefix) \
			prefix="${2}"
			if [ -z "${prefix}" ]
			then
				echo "${prg}: The ${1} option requires a string." >&2
				error=true
			else
				shift 1
			fi
			;;
		-postfix) \
			postfix="${2}"
			if [ -z "${postfix}" ]
			then
				echo "${prg}: The ${1} option requires a string." 1>&2
				error=true
			else
				shift 1
			fi
			;;
		-*)	echo "Unknown option: ${1}." >&2
			error=true
			;;
		*)	files="${files} ${1}"
			;;
	esac
	shift 1
done

if [ $error = true ]
then
cat >&2 <<_EOT_

USAGE: ${prg}	[-addcr]  [-prefix <string>]  [-postfix <string>]
		[-control <file>]  [file1]  [file2] ...

		-addcr   : Prepend a CR to each LF for DOS based printers.
		-prefix  : String to print before each file is being printed.
		-postfix : String to print after each file has been printed.
		-control : Semaphore file to be removed when program exits.

	This program prints all files specified to the slave printer attached
	to your terminal (if it can figure out the according escape sequence).

	When no files are specified, data is read from the standard input.

_EOT_
	exit 1
fi

# Check control_file
if [ ! -z "$control_file" ]
then
	if [ ! -f "$control_file" ]
	then
		echo "${prg}: Cannot find control file ${control_file}." 1>&2
		exit 1
	fi

	# This would have been a useful little test, if Kennys
	# didn't place the username into the control file...
	# if [ -s "$control_file" ]
	# then
	# 	echo "${prg}: The control file $control_file contains data! (DANGEROUS)." 1>&2
	#	exit 1
	# fi
fi

# If no files specified, read stdin.
if [ -z "$files" ]
then
	files="-"
fi

# Get escape sequences from termcap/terminfo
printer_on=`tput mc5`
printer_off=`tput mc4`

# Exception cases.
case $TERM in
	4320*	| \
	dt4320*	| \
	wyse60*	| \
	wy60*)	if [ "$printer_on" = "" ]
		then
			# Remove bad sequence, as it also prints on the tty.
			printer_on=""
		fi
esac

# If termcap/terminfo fails, try to resolve manually...
if [ -z "$printer_on" -o -z "$printer_off" ]
then
	# Fall-back: only set unknown variables
	case $TERM in
		ansi*	| \
		Ansi*	| \
		vt220*	| \
		cansi*)	printer_on=${printer_on:-"\033[5i"}
			printer_off=${printer_off:-"\033[4i"}
			;;
		4320*	| \
		dt4320*	| \
		wyse60* | \
		wy60*)	printer_on=${printer_on:-"\033d#"}
			printer_off=${printer_off:-""}
			;;
		*)	echo "${prg}: Unsupported terminal: $TERM." >&2
			exit 1
			;;
	esac
fi

printer_on="${printer_on}${prefix}"
printer_off="${postfix}${printer_off}"

# Install trap to restore output to terminal in case of an emergency.
trap 'cleanup $?' 0 1 2 3 15

# Do the actual printing
for file in $files
do
	if [ ! "$file" = "-" -a ! -r "$file" ]
	then
		echo "${prg}: Cannot open $file." 1>&2
		continue
	fi

	if [ "$file" = "-" ]
	then
		# It pays to place stdin into a temporary file first, since it
		# prevents terminal and printer output from getting mixed-up.
		# (Progress people: when you use "message" as a sign-of-life
		# while printing). For this reason (and for displaying error
		# messages) we don't redirect the output to the printer for
		# the entire printing-batch, but for individual files only.

		cat > $tmp_file
		printfile="$tmp_file"
	else
		printfile="$file"
	fi

	# Redirect output to printer
	echo "${printer_on}\c"

	if [ $addcr = false ]
	then
		cat $printfile
	else
		# Use awk to get a CR before each LF
		awk '{ printf("%s\r\n", $0) }' < $printfile
	fi

	# Redirect output back to terminal
	echo "${printer_off}\c"
done

# Done! (Removal of control and tmp_file handled by cleanup)
cleanup 0