Trouble Sending Printer Codes from Perl to Printer

David Vergin dvergin@igc.org
Fri Jul 1 00:24:00 GMT 2005


> David Vergin wrote:
>>     system(qq/echo -en "$data_str" | lpr -oraw/);
>> That does not work in cygwin.

Lasse wrote:
> Why would want use echo for this? Just use a piped open directly to lpr:
> 
>     open(FH, '| lpr -oraw');
>     print(FH, $data_str);
>     close(FH);

Thank you Lasse. <sheepish grin>

This is seriously embarrassing! I was so focussed on fixing the received 
solution, I failed to step back and look at the problem afresh.

For the sake of others who may see this exchange and want a fuller 
example, here's a quick working demo. Note the necessity of sending both 
\r and \n since we are bypassing the normal expansion that would do that 
for us. And proper error checks still need to be added.

Don't try this with these codes unless you have an old Epson inkjet 
printer or you will likely give your printer indigestion.

    open(FH, '| lpr');
    print(FH "\033X\026\030\000");    #condensed spacing
    print(FH "modified\r\nstuff\r\n");
    print(FH "\033\@");               #reset printer
    print(FH "Normal\r\nprint\r\n");
    print(FH "\f");                   #formfeed
    close(FH);

Regards,
David

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list