Using PHP to print using LP on Linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
Hi Guys,
 
I suppose this isn't a database specific question, but it is the only
PHP mailing list I am subscribed to.
 
Trying to trigger a printer in the office hooked up to a Mandrake 8 box
with PHP 4.3 to print a file remotely, using the 'lp' command.
Uses a postscript template to create the text that needs printing.
 
Opens and edits the postscript fine, the printer refuses to work using
the last section of code however.
 
Does anybody have experience using lp with PHP and Linux?
Any help appreciated.
 
Cheers.
 
My Code - 
 
 
            $filename = "new_user_letter.ps";
            $fp = fopen($filename,"r");
            $fdata = fread($fp, filesize($filename));
            fclose($fp);
 
            //search and replace all keywords....
            $fdata = ereg_replace("%%full_name%%",$fullname,$fdata);
            $fdata =
ereg_replace("%%street_address%%",$streetaddress,$fdata);
            $fdata = ereg_replace("%%town%%",strtoupper($town),$fdata);
            $fdata =
ereg_replace("%%state%%",strtoupper($state),$fdata);
            $fdata =
ereg_replace("%%postcode%%",strtoupper($postcode),$fdata);    
            $fdata = ereg_replace("%%date%%",$long_date,$fdata);   
            $fdata = ereg_replace("%%username%%",$username,$fdata);
            $fdata = ereg_replace("%%email_address%%",$username .
"@nor.com.au",$fdata);
            $fdata = ereg_replace("%%password%%",$password,$fdata);
            $fdata =
ereg_replace("%%primary_dns%%","202.147.135.10",$fdata);
            $fdata =
ereg_replace("%%secondary_dns%%","202.147.135.20",$fdata);
            $fdata =
ereg_replace("%%pop_location_and_ph_number%%",$location . " - " .
$dial_in_number,$fdata);
            $fdata =
ereg_replace("%%domain_name%%","nor.com.au",$fdata);
            $fdata =
ereg_replace("%%pop3_server%%","mail.nor.com.au",$fdata);
            $fdata =
ereg_replace("%%smtp_server%%","mail.nor.com.au",$fdata);
            $fdata =
ereg_replace("%%news_server%%","news.nor.com.au",$fdata);
            
            // Open the lp command for writing and pass the postscript
to it.
            //  The loop is to allow multiple copies to be printed,
            
           for ($copy_loop=0;$copy_loop<$num_copies;$copy_loop++){
                        $fp = popen("/usr/bin/lp -d bw_laser_raw","w");
                        fputs($fp,$fdata,strlen($fdata));
                        pclose($fp);
                        echo ".";            
            }
            

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux