A print filter for e-mail that relies on a2ps and uses no temp files. The result of this application would be that an email message, read on [stdin], would be formatted and then output (via the pipe to [a2ps]) to your system's printer. ---- #!/bin/sh # \ exec tclsh $0 ${1+"$@"} # Fun little mail message formatting tool. # Relies on a2ps. set data [ read stdin ] set output set sig 0 set header 1 set recipients 0 set hpat {\1\2
} set spat {\1\2
} # the name of the print queue to use set printer hpmlknco1 # if you want a graphic in the upper right corner # of page 1. set graphic /home/pehrens/public_html/mutt_letter.gif if { [ file readable $graphic ] } { lappend output "" } foreach line [ split $data "\n" ] { set done 0 if { $header } { # handle header lines. if { [ regsub -nocase {^(Date:|Sent:|From:)(.+)$} $line $hpat line ] } { set recipients 0 set done 1 } # might be a long list of recipients... if { [ regsub -nocase {^(To:|Cc:)(.+)$} $line $hpat line ] } { set recipients 1 set done 1 } # will be the last line of contained message headers if { [ regsub -nocase {^(Subject:)(.+)$} $line $spat line ] } { set recipients 0 set done 1 } # will generally be the last line of the header if { [ regsub -nocase {^(X-mailer:)(.+)$} $line $hpat line ] } { set recipients 0 set done 1 } # if we had a long recipients list in the "To:" or # "Cc:" field if { ! $done && $recipients && ! [ regexp : $line ] } { set line $line
set done 1 } else { set recipients 0 } # horizontal rule and blank line after header if { ! $done && $header } { set header 0 lappend output

       }
    }  
 
    # we have reached a quoted line
    if { [ regexp {^(>.+)$} $line ] } {
       set done 1
    }
 
    # we have reached a line consisting solely of dashes.
    # this should signal the start of the signature
    if { [ regexp -- {^(-+)$} $line ] } {
       set line 


       set sig 1
       set done 1
    }
 
    # we are in the body of the sig...
    if { $sig && ! [ string equal 

 $line ] } {
       set done 1
    }
 
    if { ! $done } { set line $line }
    
    # collect htmlized lines
    lappend output $line
 }
 
 set output [ join $output "\n" ]
 
 set out [ open "|a2ps --printer=$printer --pretty-print=html" a+ ]
 
 puts $out $output
 
 catch { close $out }

----
http://directory.static.net/printer http://directory.static.net/printer
Looks nice to me, but I don't know anything about TCL. I'd like to use this is a filter, i.e. writing to STDOUT instead of printing. Replacing --printer=$printer by --output=- doesn't seem to work. Can someone help me? Thanks, Jan 
----
[Category Application] | [Category Printing] | [Category Internet]