-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The Monday 2007-04-23 at 13:58 -0700, Randall R Schulz wrote:

> Thanks for elaborating the example. For some reason when I first read 
> Johannes' post, I didn't grok that "One\fTwo" were two pages of 
> sample / simulated output that would be printed with the 
> date/time-stamp page label.

I wrote an script. If you try it, don't send a long file, try it first 
with a single page, because the printed number is not very nice: a 7 
millimeter box at the top and bottom edges of the paper, rough bold type.

I don't like the code I wrote to detect if the parameters are digits, but 
its better than nothing. Very simple error detection. If there is a bad 
error when separating the pages or printing, it will not stop.


#!/bin/bash
# ~/bin/printpagewithnumber

function syntax ()
{
  echo syntax error: I expected \"start_page_number end step\"
  exit 
}


if test -n "$1" -a -n "$2" -a -n "$3"  -a -n "$4" ; then
  FILE=$1
  let "START = $2"
  let "END = $3"
  let "STEP = $4"
  if test "0$START" -gt 0  -a "0$END" -gt 0  -a "0$STEP" -gt 0 ; then  
    echo Got numbers.
  else
    echo Parameters 2..4 were not numbers
    syntax
  fi
  
  
  if test -s $FILE ; then
    echo Got file
    let "PAGE = $START"
    echo "I'm going to print from page $START to page $END in $STEP pages steps"
    while ( test $PAGE -le $END ) ; do
      echo "Selecting page $PAGE"
      psselect -p$PAGE $FILE /tmp/pagina.ps
      echo "Sending page $PAGE to default printer"
      lp /tmp/pagina.ps  -o page-label="$PAGE"
      let "PAGE = $PAGE + $STEP"
    done
  else
    echo File $FILE does not exist.
    syntax
  fi
  
else
  echo "I will print pages from start to end by steps, adding a page number 
label"
  syntax
fi

echo Done

  

- -- 
Cheers,
             Carlos E. R.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Made with pgp4pine 1.76

iD8DBQFGLTtotTMYHG2NR9URAgreAJ9wB2fS2AAtBjvWrdy64OHDffHeGwCfSF55
bzszCqYAb3fTewu3kI6f3Bs=
=v+ZD
-----END PGP SIGNATURE-----

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to