At Mon, 16 Sep 2002 08:42:56 +1000, Scott Ragen wrote:
> I have a script that reads from stdout, pipes it to a file, then converts 
> to postscript and prints it.
> What I would like to to is execute the script with an option after it.
> eg:
> rrhtml -P [EMAIL PROTECTED]
> 
> This would tell it to print to the kyocera, but how do I do this if the 
> file is also piped to stdout?
> 
> The script is as follows:
> 
> #!/bin/ksh
> DATE=`date +%s`
> DATAPATH=/u/test/murr
> htmlfile=$DATAPATH/$DATE
> cat $1 >$htmlfile
> wait $!
> htmldoc --header ... --footer ... --jpeg=2 --left 1cm --right 1cm  --size 
> a4 --webpage -t ps2 --top 1cm --bottom 1cm $htmlfile |lpr 
> [EMAIL PROTECTED]
> rm -f ${htmlfile}

rather than trying to interpret command line options yourself, just
pass them all on to lpr directly:

 #!/bin/sh
 htmldoc --header ..... | lpr "$@"

so "rrhtml -P foo@bar" ends up piping to "lpr -P foo@bar".

if you're doing this on some arcane shell (and you may well be if
you're somewhere where you need #!/bin/ksh), you might need to use
${1+"$@"} instead to correctly cope with the case where there's no
arguments passed.

-- 
 - Gus
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to