-
Print to file
is there any way of creating prn files(Print to file) automatically on linux ??
I use Php, Mysql and Apache. I take some visitor information, i put them in the db and I need to take them out, create a prn file and than sent it to one of my customers!
Is this possible????
I am thinking to use cron to run a script every few hours, but I don't know if it works for I am not using Linux!!!
I hope you will still answer me after the last statement!! :P :)
-
It's more than possible, it's really the way it works. All UNIX programs print using PostScript, it just that normally the PostScript data is directly piped into the printing program. Only very strange programs would not allow you to save it to a file instead, since files and pipes work almost exactly the same.
One advantage with PostScript is also that, if your customers don't like PostScript, it's easily converted into a diversity of other formats, like PDF.
-
so what should I do??? cause my mind is really foggy at this moment!!!
-
Well, I'm not sure just how you want it. What is it that you're doing with your system right now and what is it that you want it to do? Are you hosting multiple sites or something (considering apache and several customers)?
-
sure, this is possible. You will need to write a script of some sort though, which requires some programming technique. Lets see, here is a shell of what you need (in bash)
Code:
FILE=stuff.prn
head()
{
#echo "This is the header of my letter"
}
format()
{
#this is where you do some crazy cut/grep command to format
#the stuff the way you want it
}
body()
{
#this is where you do some crazy mysql command like:
#mysql_output=mysql -u username -ppassword -e 'select * from stuff;'
format mysql_output
}
tail()
{
#echo "This is the tail of my letter"
}
echo "What file name"
read filename
head >> $filename
body >> $filename
tail >> $filename
PS, don't trust my code, don't try and run it on anything. It might kill your cat or give your grandmother herpes or something. You never know.