Creating a print script
I am fairly new to linux and I would like to create a script that will print a file when entered into the terminal.
ie) # pprint file this command would print "file" to the printer specified in the script with the formating specified. I would like the script to format the file in 2 columns, with borders and line numbers. i would like a head that specifies when the file was printed and the name of the file. Is this possible? Does this make sense? Thanks!!!! tom |
I beleive the command-line utility enscript can do all that. See the man page for enscript for command parameters.
|
Hm.... enscript comes back unknown...... any other ideas? Thanks!
|
perhaps a2ps
for scripting within bash look at http://www.tldp.org/LDP/abs/html/index.html
`lp` or `lpr` sends print requests to print spooler probably you want to install a2ps, ghostscript and so on, if you don't know how to write postscript some useful commands for scripting `head`, `tail`, `read`, `echo` ... an example using html (for web standarts look at w3c.org), you could use xml and use `xsltproc` to convert it to html, maybe you want use redirections (pipes) - for faster execution #!/bin/sh file_in=() file_out=() file_ps=() file_head=() file_tail=() wc_out=() byte_count=() byte_count_stop=() current_matrix_row=() sign0=() sign1=() function matrix_row{ current_matrix_row=`printf "<tr><td>%s</td><td>%s</td></tr>" $sign0 $sign1` } file_in=`read -p "read from file: "` file_out=`read -p "write to file: "` file_ps=`read -p "postscript file name: "` file_head="<html><head></head><body><table>" wc_out=`wc -c` byte_count_stop=`expr match $wc_out "[0-9]*."` [ byte_count_stop-1 ] byte_count_stop=$? byte_count=${wc_out:0:$byte_count_stop} file_tail="</table></body></html>" echo -e "$file_head\n" > $file_out # here you may write some special code echo -e "$file_tail\n" > $file_out html2ps $file_out -o $file_ps lp $file_ps |
Quote:
There are various options to prettify the layout, but by default it generates two column, landscape pages, with a header containing the filename, the person that printed it, the number of pages and possibly the date (can't quite remember). You can specify the --line-numbers=1 option to get it to prefix each line with its line number. See the man page for more details. a2ps might not be installed by default, so use your package manager to add it. The same advice applies to enscript - just because it says unknown command, doesn't mean you can't add it! |
Hi.
I have used these all upon occasion, but they are rarely all installed by default ... cheers, makyo Quote:
|
Thank you all soooo much! This is what I needed! Yeah, I looked at my distro CD and found the enscript stuck on there :P The way the answer was worded made me think that it is there or it isn't and I didn't know where to go. Thanks all!!!
|
All times are GMT -5. The time now is 04:44 AM. |