Printing in linux does not seem to work

197 views
Skip to first unread message

mtmigs

unread,
Apr 27, 2017, 10:40:41 PM4/27/17
to Harbour Users
I tried posting a question about using libraries. Many people looked at it but I got no replies. So I will try a more direct approach.

I am trying to print from an old Clipper program I have since successfully compiled and run under linux. Everything seems to work except the printing. The original Clipper program would print to a dot matrix printer attached to the computer's parallel port. My linux printer does not have a parallel port so I need to print to either a usb printer or even better to a networked printer.

I have a printer defined with cups named Johns_HP_LaserJet. Having looked at several documents about printing using linux and it seems putting this line in the program should work:

SET PRINTER TO "|lpr -PJohns_HP_LaserJet"

Well it does not work. Does anyone know how to get harbour programs to print when running under linux?
 

Alain Aupeix

unread,
Apr 28, 2017, 3:11:42 AM4/28/17
to harbou...@googlegroups.com
Le 28/04/2017 à 04:40, mtmigs a écrit :

> SET PRINTER TO "|lpr -PJohns_HP_LaserJet"
>
> Well it does not work. Does anyone know how to get harbour programs to
> print when running under linux?
Sorry, but I use hwgui under linux, and it's different

I thought of :

set printer to "Johns_HP_Laserjet"

But I suppose you already have tried.
Why this pipe ?

A+

--
------------------------------------------------------------------------
Alain Aupeix
http://jujuland.pagesperso-orange.fr/
http://pissobi-lacassagne.pagesperso-orange.fr/
------------------------------------------------------------------------
U.buntu 12.04 | G.ramps 3.4.9-1 | H.arbour 3.2.0dev (2016-12-16 10:05) |
Hw.Gui 2.20-3 (2630)
------------------------------------------------------------------------

mtmigs

unread,
Apr 28, 2017, 9:27:18 AM4/28/17
to Harbour Users

set printer to "Johns_HP_Laserjet"

That just creates a file  "Johns_HP_Laserjet.prn".

matt johnson

unread,
Apr 28, 2017, 10:27:48 AM4/28/17
to harbou...@googlegroups.com
try function SETDEFAULTEXTENSIONS( .F. ) before set printer to,  will create printfile without .prn extension. 




On Friday, April 28, 2017 8:27 AM, mtmigs <tmigl...@gmail.com> wrote:



set printer to "Johns_HP_Laserjet"

That just creates a file  "Johns_HP_Laserjet.prn".
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


mtmigs

unread,
Apr 28, 2017, 7:47:20 PM4/28/17
to Harbour Users, mattfr...@yahoo.com


On Friday, April 28, 2017 at 9:27:48 AM UTC-5, matt johnson wrote:
try function SETDEFAULTEXTENSIONS( .F. ) before set printer to,  will create printfile without .prn extension. 


I do not want to print to a file. I want to print to a printer. The printer I am currently using is named "Johns_HP_Laserjet".

"Johns_HP_Laserjet" is not the name of a file to which I can print. It is the name of a printer and it seems harbour programs compiled on linux cannot print directly to a printer.

Marcelo Linha Verde

unread,
Apr 28, 2017, 10:19:14 PM4/28/17
to harbou...@googlegroups.com

Hi,

I did this: ( i'm very happy ! )

Fist: i print to temporaly spool file.
Next: __run( 'cat /tmp/spoolfile | lp -d printer' )

To direct print see contrib/hbcups

Regardless

Marcelo

--
Enviado do aplicativo myMail para Android

sexta-feira, 28 abril 2017, 08:47PM -03:00 de mtmigs tmigl...@gmail.com:

--

do...@people.net.au

unread,
Apr 28, 2017, 11:47:31 PM4/28/17
to harbou...@googlegroups.com
In any multi user system you will be printing to a file regardless of whether you are aware of it or not.  Otherwise print jobs would potentially intermix which would be an absolute disaster.
What's wrong with writing to a file and then using cupsPrintFile() to print it or shell out and use lpr?  As a bonus you can also potentially preview what will print.  Also you can give your print job a name which is useful if multiple jobs are sent to a printer.
In my opinion writing direct to the printer, if you could actually do it, is bad practice.  My understanding is that in Linux you are writing to a print queue rather than a printer which could, I believe, be serviced by more than one printer.
Let's move away from all the kludges of the MSDOS days.
Regards
Doug



On Fri 28/04/17 16:47 , mtmigs tmigl...@gmail.com sent:

matt johnson

unread,
Apr 29, 2017, 11:28:10 AM4/29/17
to harbou...@googlegroups.com
The file will be printed, then deleted.  Try it, you will like it.  It is SET( _SET_DEFEXTENSIONS, .F. ) 



António

unread,
May 29, 2017, 1:02:46 PM5/29/17
to Harbour Users

Hello,

My system prints to local POS printers with this:

local sPrinter := SET(_SET_PRINTFILE, "|lpr" )
local sDevice  := SET(_SET_DEVICE, "PRINTER" )

@ 0,0 say "Something to print"

SET
(_SET_DEVICE, sDevice)
SET
(_SET_PRINTFILE, sPrinter )


Works with local attached LPT printer. Works as well with samba shared printers, as long as they are configured as "server's default printer"

Using "|lpr -P printer_name" should also work... Are you sending properly formatted PCL documents that your printer understand ?
HTH
António


Reply all
Reply to author
Forward
0 new messages