# author Leo Maxwell, August 2011

#pssplitter- quick and dirty script to generate single pages from a multi-page postscript file,

#print them, and delete them. Used with SalsaFax to send multiple faxes from a crystal report backend.


#take stdin (captured by piper2 script) and save it as a single postscript file


cat – >/tmp/


#Count pages in postscript file


wait && a=$(grep -c %%Page: /tmp/


#split file into single pages


wait && for((i=1; i<=a; ++i ))

do psselect -p$i /tmp/ /tmp/tmpfile$



#print it to SalsaFax

wait && for((i=1; i<=a; ++i ))

do lp -d SalsaFax /tmp/tmpfile$



#delete temporary files

wait && for((i=1; i<=a; ++i ))

do rm /tmp/tmpfile$



#delete main temporary file

wait && rm /tmp/



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s