Date: Sat, 23 Feb 2002 21:20:37 -0500 From: "Jeff Jeter" <gsfgf@hotmail.com> To: "Stuart Tanner" <stuart@sigterm.com> Cc: "FreeBSD Questions" <freebsd-questions@freebsd.org> Subject: Re: Linux shell scripts Message-ID: <OE50DKpzxDPHprp5yLZ00009712@hotmail.com> References: <OE727nlT2NqFJ3sl3xb0000970f@hotmail.com> <1014513894.57377.130.camel@osiris.sigterm.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Thanks, installing bash fixed one.
The other i referred to in an earlier post regardint turboprint. It is
generated by another script which works fine. attached is the generator
script.
Here is the output:
OUTPUT:
bsd# turboprint -Plp testpage-a4.ps output.prn
turboprint - executing tpfilter manually
printer name: lp
spool directory: turbo2
*** calling tpfilter now ***
head: illegal line count -- 1c
eval: 1: Syntax error: "(" unexpected
*** tpfilter finished ***
the output file may be copied to the printer now
for example: cat [OUTPUTFILE] > /dev/lp0
bsd#
Thanks
Jeff Jeter
----- Original Message -----
From: "Stuart Tanner" <stuart@sigterm.com>
To: "Jeff Jeter" <gsfgf@hotmail.com>
Cc: "FreeBSD Questions" <freebsd-questions@freebsd.org>
Sent: Saturday, February 23, 2002 8:24 PM
Subject: Re: Linux shell scripts
> On Sun, 2002-02-24 at 13:17, Jeff Jeter wrote:
> > I have several apps that use shell schripts. THese apps are designed
for linux. when i run these scripts with sh i get odd errors such as Syntax
error: unexpected ")" and
> > function: not found
> > Syntax error: unexpected "}".
> >
> > I ran the one of them w/ the unexpected "}" w/ csh, and tcsh got this
error.
> > CONFARGS=--enable-opengl: Connand not found
> > prefix=/usr/local: command not found
> > prefix: undefined variable
> >
> > How do i geth these working. I can post the (t)csh output from the
other script if needed.
>
> Are the shells that the scripts are written for installed?
>
> --
> Stuart Tanner <stuart@sigterm.com>
>
> Dave Mack: "Your stupidity, Allen, is simply not up to par."
> Allen Gwinn: "Yours is."
>
>
[-- Attachment #2 --]
#! /bin/sh
#
# tpfilter - line printer input filter for turboprint driver system
#
# Copyright 2000,2001 ZEDOnet
# Version 1.01
# Created 12.4.2000 Florian Zeiler <zeiler@turboprint.de>
# 17.11.2000: improved lprng compatibility (flags, don't use rewindstdin)
# 27.04.2001: DVI printing implemented
#
PATH=/bin:/usr/bin:/usr/local/bin
PATH=${PATH}:/usr/bin/TeX:/usr/X11R6/bin
PATH=${PATH}:/sbin:/usr/sbin
#export PATH
# get Turboprint paths
eval $(cat "/etc/turboprint/system.cfg")
LOGFILE="$TPPATH_LOG/turboprint_lpr.log"
TPSTDIN="$TPPATH_FILTERS/tpstdin"
SMBPRINT="$TPPATH_FILTERS/smbprint"
SOCKETPRINT="$TPPATH_FILTERS/socketprint"
NCPPRINT="$TPPATH_FILTERS/ncpprint"
echo >> $LOGFILE
echo "-----------------------------" >> $LOGFILE
echo "New print job $(date) - command line:" >> $LOGFILE
echo $* >> $LOGFILE
# parse parameters
# lpr:
# -c -wwidth -llength -iident -n login -h host acct-file
# LPRng:
# -Ffileformatcharacter -ejobdatafile -kcontrolfile
# -Hhost -Jjob -Llogin -Pprintername -Qqueue -aacct-file -dspooldir -fjobfilename
# -hhost -jjobnumber -llength -nlogin -wwidth -xxpos -yypos acct-file
# -c means transmit file unchanged ("raw") to printer
#
while [ -z "${1%%-*}" -a -n "$1" ] ; do
temp="${1#-}"
shift
case "$temp" in
a*) # account file (lprng)
{
ACCOUNTFILE="${temp#?}"
};;
e*) # data file (lprng)
{
DATAFILE="${temp#?}"
};;
f*) # job name (lprng)
{
JOBFILE="${temp#?}"
};;
h*) # host name
{
HOST="${temp#?}"
if [ -z "$HOST" ] ; then
HOST="$1"; shift
fi
};;
j*) # job name (lpr) or number (lprng)
{
JOB="${temp#?}"
if [ -z "$JOB" ] ; then
JOB="$1"; shift
fi
};;
n*) # login name
{
LOGIN="${temp#?}"
if [ -z "$LOGIN" ] ; then
LOGIN="$1"; shift
fi
};;
*);; # other flags: ignore
esac
done
# account file set by -a or is last parameter
if [ -z "$ACCOUNTFILE" ] ; then
eval temp="\${$#}"
if [ -n "$temp" -a "$temp" != "$0" ]; then
ACCOUNTFILE="$temp"
fi
unset temp
fi
# job name set by -f (lprng) or -j (lpr)
if [ $JOBFILE ] ; then
JOB="$JOBFILE"
fi
# the spool path is the path to the account file
SPOOLPATH=$(dirname $ACCOUNTFILE)
# the configuration name is the last part the spool path
CONFIGNAME=$(basename $SPOOLPATH)
# create a temporary file
TEMPFILE="$TPPATH_TEMP/tpfilter$$.tmp"
# find user's home directory
#
YPD="`domainname`"
YPS="`grep -E '^\+' /etc/passwd|head -1c`"
if [ -n "$YPD" -a "$YPS" = "+" ] ; then
set -- `(cat /etc/passwd; ypcat passwd)|grep "^$LOGIN:"|cut -d':' -f6`
else
set -- `grep "^$LOGIN:" /etc/passwd |cut -d':' -f6`
fi
HOMEDIR="$1"
# the global config file is in the spool path
CONFIGFILE="$SPOOLPATH/tpprinter.cfg"
# the user config file is in the home directory
USERCONFIG="$HOMEDIR/.turboprint/$CONFIGNAME.cfg"
echo "CONFIGNAME=$CONFIGNAME CONFIGFILE=$CONFIGFILE USERCONFIG=$USERCONFIG" >> $LOGFILE
echo "JOB=$JOB DATA=$DATAFILE LOGIN=$LOGIN HOST=$HOST HOMEDIR=$HOMEDIR TEMP=$TEMPFILE" >> $LOGFILE
# evaluate config files; user settings overwrite global settings
eval $(cat $CONFIGFILE)
# user config: put "declare" in front of file (security)
if [ -e "$USERCONFIG" ] ; then
eval $(echo "declare " $(cat $USERCONFIG))
fi
# check for file header, cut off a chunk for filetype determination
eval $($TPSTDIN --cut $TEMPFILE)
if [ $TPHEADER -a $TPHEADER = "raw" ] ; then
FILETYPE="tpraw"
else
# get mime file type using command "file"
# translate output to upper case
FILETYPE=$(file $TEMPFILE | tr 'A-Z' 'a-z')
echo "filetype=$FILETYPE" >> $LOGFILE
fi
# select input filter depending on file type
case "$FILETYPE" in
tpraw)
# raw printer commands from tpconfig
{
USEGS=0;
};;
# first the formats that go through ghostscript
*postscript*)
# postscript: this is our preferred input
{
# do nothing
INPUTFILTER="";
USEGS=1;
};;
*pdf*document*)
# portable document format:
# almost the same as postscript ??
{
# do nothing
# possibly a temp file is needed...???
INPUTFILTER="";
USEGS=1;
};;
*fig*image*text*)
# fig drawing
{
# use fig2dev
# -Lps - language = postscript
# -P - don't create eps but printable ps file
# -c - center on page
INPUTFILTER="fig2dev -Lps -P -c | ";
USEGS=1;
};;
*tex*dvi*file*)
# tex dvi document
{
TEMPFILE1="$TPPATH_TEMP/tpfilter$$.tmp1"
INPUTFILTER="cat - > $TEMPFILE1 | dvips -f $TEMPFILE1 | "
TPCOLORMODE=0
USEGS=1;
};;
*troff*preprocessor*)
# groff document
{
# use grog
# -S - safer mode
# -Tps - output format = postscript
GROGCMDLINE=$( grog -S -Tps $TEMPFILE)
INPUTFILTER="$GROGCMDLINE | "
TPCOLORMODE=0
USEGS=1;
};;
*html*)
# html document
{
# use html2ps
# -e - charset
# -u - underline links
# -H - use hyphenation
INPUTFILTER="html2ps -e ISO-8859-1 -u -H | ";
TPCOLORMODE=0
USEGS=1;
};;
# bitmap images that are handled directly by turboprint
*pc*bitmap*data*)
# bmp image
{
# use bmptoppm; ppm is read by turboprint
# the problem with p*m formats is that there
# is no picture size (dpi) information
INPUTFILTER="bmptoppm | ";
USEGS=0;
};;
*tiff*image*data*)
# tiff image
{
# use tifftopnm; pnm is read by turboprint
INPUTFILTER="tifftopnm | ";
USEGS=0;
};;
*gif*image*data*)
# tiff image
{
# use giftopnm; pnm is read by turboprint
INPUTFILTER="giftopnm | ";
USEGS=0;
};;
*jpeg*image*data*)
# gif image
{
# use djpeg; output format pnm is read by turboprint
# todo: options for djpeg...?
INPUTFILTER="djpeg | ";
USEGS=0;
};;
*pgm*|*pbm*|*ppm*)
# portable grey/bit/pixmap image
{
# pnm is read by turboprint
INPUTFILTER="";
USEGS=0;
};;
*sun*raster*image*data*)
# sunraster image
{
# use rasttopnm; pnm is read by turboprint
# todo: options for rasttopnm...?
INPUTFILTER="rasttopnm | ";
USEGS=0;
};;
# pcx not (yet) known by 'file'
# finally raw ascii
*)
# default - interpret as ascii text
{
# todo:
# - set page size
# - ...?
# if a2ps doesn't exist, use enscript, else ??
A2PSCOMMAND="a2ps"
type a2ps &> /dev/null || A2PSCOMMAND="enscript"
A2PSOPTIONS="--output=-"
if [ $A2PSCOMMAND = "a2ps" ] ; then
A2PSOPTIONS="$A2PSOPTIONS --medium=$A2PSMEDIUM"
else
A2PSOPTIONS="$A2PSOPTIONS --media=$A2PSMEDIUM"
fi
# either use defaults or set landscape / number of columns
if [ $A2PSDEFAULTS -ne 1 ]; then
if [ $A2PSLANDSCAPE -eq 1 ]; then
A2PSOPTIONS="$A2PSOPTIONS --landscape"
else
A2PSOPTIONS="$A2PSOPTIONS --portrait"
fi
if [ $A2PSHEADERS -eq 0 ]; then
A2PSOPTIONS="$A2PSOPTIONS --no-header"
else
if [ $JOB ]; then
if [ $A2PSCOMMAND = "a2ps" ] ; then
A2PSOPTIONS="$A2PSOPTIONS --center-title=$JOB"
else
A2PSOPTIONS="$A2PSOPTIONS --title=$JOB"
fi
fi
fi
if [ $A2PSCOMMAND = "a2ps" ] ; then
A2PSOPTIONS="$A2PSOPTIONS --borders=$A2PSBORDERS"
else
if [ $A2PSBORDERS -eq 1 ] ; then
A2PSOPTIONS="$A2PSOPTIONS --borders"
fi
fi
A2PSOPTIONS="$A2PSOPTIONS --columns=$A2PSCOLUMNS"
fi
INPUTFILTER="$A2PSCOMMAND $A2PSOPTIONS | "
TPCOLORMODE=0
GSDRIVER="pbmraw"
USEGS=1
};;
esac
# end of input filter selection
# select output filter for printing to a remote printer
echo "output=$REMOTEOUTPUT" >> $LOGFILE
remote="remote"
case $REMOTEOUTPUT in
device)
{
# no output filter needed
OUTPUTFILTER="";
};;
file)
{
# to be implemented
OUTPUTFILTER=" | cat > $PRINTTOFILE";
};;
remote)
{
# lpr queue on other unix machine
# the "old" bsd lpr doesn't filter remote output, so
# output is redirected to a second queue - the remote queue
LPROPTIONS="-P$CONFIGNAME$remote"
if [ $LOGIN ]; then
LPROPTIONS="$LPROPTIONS -U '$LOGIN'"
fi
OUTPUTFILTER=" | lpr $LPROPTIONS";
};;
smb)
{
# print to a Windows machine via SAMBA
# handled by the smbprint script
# configfile with server name, printer name, etc.
# is passed on to this script
OUTPUTFILTER=" | $SMBPRINT $CONFIGFILE";
};;
socket)
{
# print to a network printer or server box port
# handled by the socketprint script
# configfile with server name, port number
# is passed on to this script
OUTPUTFILTER=" | $SOCKETPRINT $CONFIGFILE";
};;
ncp)
{
# *** NOT YET TESTED ***
# print to a Netware server via SAMBA
# handled by the ncpprint script
# configfile with server name, printer name, etc.
# is passed on to this script
OUTPUTFILTER=" | $NCPPRINT $CONFIGFILE";
};;
esac
# end of output filter selection
# build command line for ghostscript
# -sDEVICE= name of output format
# -r resolution
# -g output image size in pixels
# -dSAFER interpret postscript in read-only mode
# -dNOPAUSE don't wait after page end
# -dBATCH don't wait after file end
# -sOutputFile= name of output file
# - instead of input file: read from stdin
# (alternative: /dev/fd/0 device name of stdin)
GSCOMMANDLINE="gs -sDEVICE=$GSDRIVER -r${GSXDPI}x$GSYDPI -g${GSWIDTH}x$GSHEIGHT\
-dSAFER -dNOPAUSE -dBATCH"
if [ $GSBUFFER -gt 0 ]; then
GSCOMMANDLINE="$GSCOMMANDLINE -dBufferSpace=$GSBUFFER"
fi
if [ $GSSCREENLPI -gt 0 ]; then
GSCOMMANDLINE="$GSCOMMANDLINE -dDITHERPPI=$GSSCREENLPI"
fi
# swap odd pages upside-down in duplex mode
#if [ $TPDUPLEX -eq 2 ]; then
# GSCOMMANDLINE="pstops -q '2:0,1U@1(1w,1h)' | $GSCOMMANDLINE"
#fi
TPCOLORSETTINGS="t${TPTRUEMATCH}x${TPMIRROR}"
if [ $TPUSERCOLOR -gt 0 ]; then
TPCOLORSETTINGS="${TPCOLORSETTINGS}b${TPBRIGHTNESS}o$TPCONTRAST"
TPCOLORSETTINGS="${TPCOLORSETTINGS}i${TPINKVOLUME}s$TPCOLORSATURATION"
TPCOLORSETTINGS="${TPCOLORSETTINGS}g$TPSCREENGAMMA"
TPCOLORSETTINGS="${TPCOLORSETTINGS}y${TPIYELLOW}m$TPIMAGENTA"
TPCOLORSETTINGS="${TPCOLORSETTINGS}c${TPICYAN}k$TPIBLACK"
fi
if [ $USEGS -eq 1 ] ; then
# command line for turboprint (called from ghostscript)
# -s width x height in 1/1000 inches
# -p left x top position in 1/1000 inches
# -a0 ignore original image aspect
# -v2 print all debug messages
# -d driver name
# -c cartridge id number
# -q quality id number
# -m paper ("medium") id number
# -g color mode (0=bw, 1=grey, 2=color)
# -f page size id number
# -i input feed id number
# -o output tray id number
# -u duplex mode id number
# -t dithering mode id number
# - instead of input&output file: use stdin/stdout
TPCOMMANDLINE="tpprint -s${TPWIDTH}x$TPHEIGHT -p${TPLEFT}x$TPTOP -a0 -v2\
-d$TPDRIVER -c$TPCARTRIDGE -q$TPQUALITY -m$TPPAPER -g$TPCOLORMODE\
-f$TPPAGESIZE -i$TPFEED -o$TPTRAY -u$TPDUPLEX -t$TPDITHERING\
-y$TPCOPIES -b$TPCOLORSETTINGS -l$LOGFILE - -"
else
# command line for turboprint image printing (called directly)
# -s width x height in 1/1000 inches
# -v2 print all debug messages
# -p left x top position in 1/1000 inches
# -a keep original image aspect ratio
# -e ignore unprintable margins
# -d driver name
# -c cartridge id number
# -q quality id number
# -m paper ("medium") id number
# -g color mode (0=bw, 1=grey, 2=color)
# -f page size id number
# -i input feed id number
# -o output tray id number
# -u duplex mode id number
# -t dithering mode id number
# - instead of input&output file: use stdin/stdout
if [ $TPPICCENTERX -eq 1 ] ; then
TPPICLEFT="c"
fi
if [ $TPPICCENTERY -eq 1 ] ; then
TPPICTOP="c"
fi
TPCOMMANDLINE="tpprint -s${TPPICWIDTH}x$TPPICHEIGHT -v2\
-p${TPPICLEFT}x$TPPICTOP -a$TPPICASPECT -e$TPPICNOMARGINS\
-d$TPDRIVER -c$TPCARTRIDGE -q$TPQUALITY -m$TPPAPER -g$TPCOLORMODE\
-f$TPPAGESIZE -i$TPFEED -o$TPTRAY -u$TPDUPLEX -t$TPDITHERING\
-y$TPCOPIES -b$TPCOLORSETTINGS -l$LOGFILE - -"
fi
echo "command lines" >> $LOGFILE
echo "gs: $GSCOMMANDLINE" >> $LOGFILE
echo "tp: $TPCOMMANDLINE" >> $LOGFILE
TPPIPE="$TPCOMMANDLINE $E2RCOMMANDLINE $OUTPUTFILTER"
echo "usegs: $USEGS" >> $LOGFILE
INPUTFILTER="$TPSTDIN --paste $TEMPFILE | $INPUTFILTER"
if [ $USEGS -eq 1 ] ; then
COMPLETEPIPE="$INPUTFILTER $GSCOMMANDLINE -sOutputFile=>($TPPIPE) - >> $LOGFILE"
else
COMPLETEPIPE="$INPUTFILTER $TPPIPE"
fi
if [ "$FILETYPE" = "tpraw" ] ; then
COMPLETEPIPE="$TPSTDIN --paste $TEMPFILE $OUTPUTFILTER"
fi
echo "complete: $COMPLETEPIPE" >> $LOGFILE
# now execute ghostscript & other pipe commands
echo "------- before execution of pipe --------" >> $LOGFILE
eval bash $COMPLETEPIPE
echo "------- end of print job --------" >> $LOGFILE
rm $TEMPFILE >> $LOGFILE
if [ -e "$TEMPFILE1" ] ; then
rm $TEMPFILE1 >> $LOGFILE
fi
exit 0
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OE50DKpzxDPHprp5yLZ00009712>
