Hey dhoubrechts,
My MUA believes you used Mozilla 4.75 [fr] (X11; U; Linux 2.2.17-21mdk i686)
to write the following on Saturday, January 11, 2003 at 6:06:11 PM.
d> It's just what I want to do, a new sheet of paper out of the
d> printer. I'm waiting for your page on next monday
Here it is, very old code, and not done as I would do it now, but it
has what you were looking for in "sub BuildFile".
This code uses Perl to display a web page w/ a form. You put the IP
of the printer in and it writes a temp file, and sends it on to the
printer via the LPR command in the path. I don't think I would write
the raw http, or a temp file if I were to build it today, but...
,----- [ ]
| #!/usr/bin/perl -w
| $FN="PrintTest2.tmp";
| $File="$ENV{TMP}\\$FN";
|
| $AdditionalFirstLineString = "\tFax this page to xxxxxxxxx!";
| $AdditionalFirstLineString = "";
| $SecondCopy="10.11.151.120";
| &DTS();
|
| &printHTML1();
| &DoTheWork();
| &printHTML2();
|
| sub DoTheWork {
| print "Printing from $ENV{'HTTP_HOST'}<p>";
| #print $ENV{'CONTENT_LENGTH'}; # testing
| if ($ENV{'CONTENT_LENGTH'} > 9) {
| read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # STDIN > $buffer for
|,#bytes
| @pairs = split(/&/, $buffer); # Split the Key-Value pairs
| foreach $pair (@pairs) { # populate an Associative Array
| ($Key, $Val) = split(/=/, $pair);
| $formHash{$Key} = $Val;
| if ($formHash{IPAddress} eq "EnterIPAddress") {
| print "ERROR: Go back and Enter IP Address";
| } else {
| &BuildFile();
|
| @LPRparms =
|("-S","$formHash{IPAddress}","-P","PORT1","-ol","$File");
| print "lpr","@LPRparms";
| @output = `lpr @LPRparms`;
| print "<p> @output";
|
| }
| }
| } else {
| &InitialForm();
| }
| }
|
| sub InitialForm {
| print <<PRINT;
| <form name=FRM method=POST action=/cgi-bin/PrintTest.pl>
| lpr -S<td><input type=text name="IPAddress" size="14" value="EnterIPAddress"
|value="10.11.151.33"> -P PORT1 -ol filename.ext
| <br><input type=submit value="Print" > <input type=reset>
| </form>
| PRINT
| }
|
| sub BuildFile {
| $Duplex = "\&l1S"; # this is the PCL5 code to duplex.
| open (LOG, ">$File");
| print LOG "$Duplex $DTS $AdditionalFirstLineString\n\n\n";
| print LOG <<EOL;
| \tThis is a test print using LPR\t from http server at $ENV{'HTTP_HOST'}
| \tprinting to $formHash{IPAddress} \t(from http client at $ENV{'REMOTE_HOST'})\n
| \tLPR syntax is:\n
| \tlpr -S ipAddr -P printQueue -ol FileName.ext
| \t\tWhere:
| \t\t-S is the IP Address or hostname of the Print Server
| \t\t-P is the Print Queue name
| \t\t-ol puts LPR in binary mode.\n\n
| \tThe LPR line used for this printout was:\n
| \t lpr -S $formHash{IPAddress} -P PORT1 -ol $FN\n\n
| \tWe are also testing duplex printing (both sides of the paper).
| \tIf the duplex print was successful, there should be text on
| \tboth sides of the paper, if not, you should have 2 pages!
| \n\tThis should be the first line on the second page!
| EOL
| # ^L above is the form feed char of 012 ascii
| close (LOG);
| }
|
| sub printHTML1 {
| print "Content-type: text/html\n\n"; # Set the Content type first!
| print <<HTMLdone1;
| <HTML>
| <HEAD> <TITLE>Print Test</TITLE> </HEAD>
| <BODY>
| <center>
| HTMLdone1
| }
|
| sub printHTML2 {
| print <<Sig;
| <p><a href="javascript:history.go(-1)">Back</a>
| <!--BR>Code written by Timothy L Musson, IBM Global Services--></I>
| <!--$0-->
| </BODY>
| </HTML>
| Sig
| }
|
| sub DTS { #Sec=$T[0],M=1,H=2, mDay=3,Mon=4,Yr=5, wDay=6,yDay=7, isdst=8
| (@T)=localtime(time); $jDay=++$T[7]; $Year=$T[5]+1900;
| $DTS="$Year/$T[4]/$T[3] $T[2]:$T[1]:$T[0]";
| }
|
| exit();
`-----
My mail client picked that tag line from a large file! - go figure.
--
Tim Musson
Flying with The Bat! eMail v1.62 Christmas Edition
Windows 2000 5.0.2195 (Service Pack 2)
use Perl; \ program \ fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]