OK. I get it. Been spending way too many hours on this but GC can't directly print to a printer on Linux. Disappointing, as I look to convert 35 year old RM/COBOL programs that used a simple "ASSIGN TO PRINT "PRINTER". That's all that was needed to magically send to the lp command.
But I can't find any explicit step-by-step examples. All I've found is basically 'send to a text file, then call SYSTEM to print the text file.' But what happens when a bunch of people are printing to that same text file? The only recourse I see is to CALL C$GETPID and create a dynamic output file name.
Is there a short (ha!) COBOL example program that just sends "Hello World!" to a printer?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Under Linux the normal method is to use the default spooler, cups.
You assign a command using variable starting with lpr ending with the
name of the spooler / printer.
In between is the configuration for font, size, margins etc..
For the assign use ASSIGN "temp-print-name" and I use by habit "prt-1",
"prt-2" when use lpr with that file name with such a command as : -
> Landscape
01 Print-Report.
03 filler pic x(117) value
"lpr -r -o 'orientation-requested=4 page-left=21 page-top=48 " &
"page-right=10 sides=two-sided-long-edge cpi=12 lpi=8' -P ".
03 PSN pic x(48) value "Smart_Tank_7300 ". >
This is the Cups print spool, change it for yours
03 PP-Name pic x(24) value "prt-1". > Don't change
this line 18/02/23 was X(15) >
Changing PSN for the spool name
and PP-Name for the one used in the assign
Then issue it using :
call "SYSTEM" using print-report.
Having ensured you actually have o/p to it first as it save wasting a
sheet of paper..
The above example is for landscape printing but for portrait I use :
> > 2023/02/18 vbc - Added PP-Name and Print-File-Name - Portrait >
01 Print-Report.
03 filler pic x(117) value
"lpr -r -o 'orientation-requested=3 page-left=36 page-top=24 " &
"page-right=24 sides=two-sided-long-edge cpi=12 lpi=8' -P ".
03 PSN pic x(48) value "Smart_Tank_7300 ". >
This is the Cups print spool, change it for yours
03 PP-Name pic x(24) value "prt-1". > Don't change
this line 2023-02-18 chngd from 15 >
PP-Name need to be large enough for any names you create.
PSN "Should" be large enough already.
On 08/04/2024 23:16, John Ritter wrote:
OK. I get it. Been spending way too many hours on this but GC can't
directly print to a printer on Linux. Disappointing, as I look to
convert 35 year old RM/COBOL programs that used a simple "ASSIGN TO
PRINT "PRINTER". That's all that was needed to magically send to the
lp command.
But I can't find any explicit step-by-step examples. All I've found is
basically 'send to a text file, then call SYSTEM to print the text
file.' But what happens when a bunch of people are printing to that
same text file? The only recourse I see is to CALL C$GETPID and create
a dynamic output file name.
Is there a short (ha!) COBOL example program that just sends "Hello
World!" to a printer?
I did something similar, but my "Print-Report" name includes a process ID number so I don't have to worry about 2 users writing to the same file at the same time. I also have been using enscript instead of either lp or lpr because enscript recognizes a ENSCRIPT environment variable that each user can set to what they want. I don't know of such options for lp or lpr. Somebody might want a bigger font, or landscape vs. portrait and they can set it individually. Enscript doesn't seem to understand many CUPS options like you use, but fortunately I'm not there yet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I did something similar, but my "Print-Report" name includes a process
ID number so I don't have to worry about 2 users writing to the same
file at the same time. I also have been using enscript instead of
either lp or lpr because enscript recognizes a ENSCRIPT environment
variable that each user can set to what they want. I don't know of
such options for lp or lpr. Somebody might want a bigger font, or
landscape vs. portrait and they can set it individually. Enscript
doesn't seem to understand many CUPS options like you use, but
fortunately I'm not there yet.
I have a script that runs against the lpt-xx file that produces a pdf
file that in turn then prints if needed - see below for a sample :
13/12/2018 vbc - Tested with Mageia v6 X64 and Raspberry Pi 3B+
I also tried this program. It writes a file with the name in quotes as the file name and the data is in that file.
But the lp command works as a command line of: echo "asdfasdfasdf" |lp -2 -dHPprintername
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I may fiddle around with other options, perhaps, COB_DISPLAY_PRINT_PIPE and other environment variables... I will put on my projects to do list ! now .... back to work !
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK. I get it. Been spending way too many hours on this but GC can't directly print to a printer on Linux. Disappointing, as I look to convert 35 year old RM/COBOL programs that used a simple "ASSIGN TO PRINT "PRINTER". That's all that was needed to magically send to the lp command.
But I can't find any explicit step-by-step examples. All I've found is basically 'send to a text file, then call SYSTEM to print the text file.' But what happens when a bunch of people are printing to that same text file? The only recourse I see is to CALL C$GETPID and create a dynamic output file name.
Is there a short (ha!) COBOL example program that just sends "Hello World!" to a printer?
Under Linux the normal method is to use the default spooler, cups.
You assign a command using variable starting with lpr ending with the
name of the spooler / printer.
In between is the configuration for font, size, margins etc..
For the assign use ASSIGN "temp-print-name" and I use by habit "prt-1",
"prt-2" when use lpr with that file name with such a command as : -
> Landscape
01 Print-Report.
03 filler pic x(117) value
"lpr -r -o 'orientation-requested=4 page-left=21 page-top=48 " &
"page-right=10 sides=two-sided-long-edge cpi=12 lpi=8' -P ".
03 PSN pic x(48) value "Smart_Tank_7300 ". >
This is the Cups print spool, change it for yours
03 PP-Name pic x(24) value "prt-1". > Don't change
this line 18/02/23 was X(15)
>
Changing PSN for the spool name
and PP-Name for the one used in the assign
Then issue it using :
call "SYSTEM" using print-report.
Having ensured you actually have o/p to it first as it save wasting a
sheet of paper..
The above example is for landscape printing but for portrait I use :
>
> 2023/02/18 vbc - Added PP-Name and Print-File-Name - Portrait
>
01 Print-Report.
03 filler pic x(117) value
"lpr -r -o 'orientation-requested=3 page-left=36 page-top=24 " &
"page-right=24 sides=two-sided-long-edge cpi=12 lpi=8' -P ".
03 PSN pic x(48) value "Smart_Tank_7300 ". >
This is the Cups print spool, change it for yours
03 PP-Name pic x(24) value "prt-1". > Don't change
this line 2023-02-18 chngd from 15
>
PP-Name need to be large enough for any names you create.
PSN "Should" be large enough already.
On 08/04/2024 23:16, John Ritter wrote:
I did something similar, but my "Print-Report" name includes a process ID number so I don't have to worry about 2 users writing to the same file at the same time. I also have been using enscript instead of either lp or lpr because enscript recognizes a ENSCRIPT environment variable that each user can set to what they want. I don't know of such options for lp or lpr. Somebody might want a bigger font, or landscape vs. portrait and they can set it individually. Enscript doesn't seem to understand many CUPS options like you use, but fortunately I'm not there yet.
On 09/04/2024 01:58, John Ritter wrote:
I have a script that runs against the lpt-xx file that produces a pdf
file that in turn then prints if needed - see below for a sample :
13/12/2018 vbc - Tested with Mageia v6 X64 and Raspberry Pi 3B+
using its standard Debian Linux build.
enscript --quiet --no-header -h -L 60 --font=Courier8@8/8 --landscape
--margins=30:30:10:10 -M A4 -p - logbook.rpt | ps2pdf14 - logbook.pdf
exit 0
This one is for my pilots flight logging program.
Since this is your problem and not mine, have you tried:
SELECT PRINT-FILE ASSIGN TO "|lp -dqueue_name".
I also tried this program. It writes a file with the name in quotes as the file name and the data is in that file.
But the lp command works as a command line of: echo "asdfasdfasdf" |lp -2 -dHPprintername
Thanks, but that was about the third or fourth experiment, and no, it doesn't work. I'm sticking to my original method.
I changed the select line:
select print-file assign to '/dev/stdout'
and changed the execution to ./testprt |lp -ddestination
That works! much like display from sysout, but more control....
I may fiddle around with other options, perhaps, COB_DISPLAY_PRINT_PIPE and other environment variables... I will put on my projects to do list ! now .... back to work !