TCPIP Printer Spooling Question - How to spool from applicat

Hello,
I am using QNX4.25 and have set up a remote printer using the TCPIP
based printer spooling system. I use lpr to print files. This all
works fine.

I have an application that generates postscript printer files and I
would like to spool these files from the application w/o the user
having to use lpr. I imagine that I could do this:

system(“lpr -P nec filename.ps”);

to print ‘filename.ps’ on the ‘nec’ printer. I was wondering if there
is a more elegant way to do this w/o calling a utility program. Maybe
I can send a message to a process or something?

If you have an idea and could point me in the direction of some
documentation that would be great!

Thanks for your time,
Greg Laird

You should be able to open a pipe, spwan lpr with “-P” and
“nec” args and write your file to the pipe.

If you also have lpsrvr running, there can be and entry in
/dev/spool/ that you can write to directly.

Richard

Greg Laird wrote:

Hello,
I am using QNX4.25 and have set up a remote printer using the TCPIP
based printer spooling system. I use lpr to print files. This all
works fine.

I have an application that generates postscript printer files and I
would like to spool these files from the application w/o the user
having to use lpr. I imagine that I could do this:

system(“lpr -P nec filename.ps”);

to print ‘filename.ps’ on the ‘nec’ printer. I was wondering if there
is a more elegant way to do this w/o calling a utility program. Maybe
I can send a message to a process or something?

If you have an idea and could point me in the direction of some
documentation that would be great!

Thanks for your time,
Greg Laird

Hi Richard,
Thanks for your post. I am using the TCPIP print spooling routines so
I will not be using lpsrvr (though I like the idea of writing to
/dev/spool…). I also like your idea of spawning lpr and then
writing my data to a pipe. I think this is what I will do.

One question: I will generate a file for printing every few minutes
and would like the file to be spooled immediately after I have
completed writing it. The way I imagine this would work would be:

aa:
create pipe
spawn lpr and pass fd for read side of pipe
write my postscript data into write side of pipe
close my write side of the pipe when done with page
go to aa

I am guessing that lpr will not release the file to the spooler until
it reads and EOF on the file. The only way that I can send an EOF is
to close the writing end of the pipe.

When lpr receives an EOF, I also imagine that it will terminate so I
will have to respawn it for every file I write. I would be great to
not have to respawn this program repeatedly.

Any comments or ideas?

Thanks again,
Greg Laird

On Wed, 14 Mar 2001 20:36:37 -0500, “Richard R. Kramer”
<rrkramer@kramer-smilko.com> wrote:

You should be able to open a pipe, spwan lpr with “-P” and
“nec” args and write your file to the pipe.

If you also have lpsrvr running, there can be and entry in
/dev/spool/ that you can write to directly.

Richard

Greg Laird wrote:

Hello,
I am using QNX4.25 and have set up a remote printer using the TCPIP
based printer spooling system. I use lpr to print files. This all
works fine.

I have an application that generates postscript printer files and I
would like to spool these files from the application w/o the user
having to use lpr. I imagine that I could do this:

system(“lpr -P nec filename.ps”);

to print ‘filename.ps’ on the ‘nec’ printer. I was wondering if there
is a more elegant way to do this w/o calling a utility program. Maybe
I can send a message to a process or something?

If you have an idea and could point me in the direction of some
documentation that would be great!

Thanks for your time,
Greg Laird

Previously, Greg Laird wrote in qdn.public.qnx4:

Hi Richard,
Thanks for your post. I am using the TCPIP print spooling routines so
I will not be using lpsrvr (though I like the idea of writing to
/dev/spool…). I also like your idea of spawning lpr and then
writing my data to a pipe. I think this is what I will do.

Can you not use lpd instead of lpsrvr, and then write to the
/dev/spool file that lpd creates? Direct lpd to your networked
printer. Now all you have to do to print your file is:

  1. cat file to printer
    or
  2. open, write, close on the /dev/spool entry.

Cheers,
Andrew

Previously, Greg Laird wrote in qdn.public.qnx4:

Hello Andrew,
I am using lpd. Your idea sounds perfect to me. I am not sure which
file to write to in /dev/spool. Do you know? Is it documented
somewhere?

I was vastly oversimplifying in my previous post (ok, misleading).
You actually need to run both lpd and lpsrvr in order to make this
work. The reference in the TCP/IP 4.25 helpviewer documentation is:

/usr/help/product/tcpip_4.25_en/user_guide/printing.html

Example 4 on this page talks about using both lpd and lpsrvr

Essentially, you set up lpsrvr normally, but change its copy-out rule
(co=) to call lpr to print to the lpd printer, which you set up to
point to a remote printer via TCP.

Andrew

Hello Andrew,
I am using lpd. Your idea sounds perfect to me. I am not sure which
file to write to in /dev/spool. Do you know? Is it documented
somewhere?

Thanks again,
Greg


On Thu, 15 Mar 2001 08:57:54 +0000, Andrew Thomas <Andrew@cogent.ca>
wrote:

Previously, Greg Laird wrote in qdn.public.qnx4:
Hi Richard,
Thanks for your post. I am using the TCPIP print spooling routines so
I will not be using lpsrvr (though I like the idea of writing to
/dev/spool…). I also like your idea of spawning lpr and then
writing my data to a pipe. I think this is what I will do.

Can you not use lpd instead of lpsrvr, and then write to the
/dev/spool file that lpd creates? Direct lpd to your networked
printer. Now all you have to do to print your file is:

  1. cat file to printer
    or
  2. open, write, close on the /dev/spool entry.

Cheers,
Andrew

I don’t know enough about the internals of lpr/lpd to give an
authoritative answer. Looking at the black-box behavior of lpd,
however, it appears that lpd looks in usr/spool/lpd/
for pairs of files named a certain way. One file is the job to be
printed, the other is some housekeeping info (I can guess at the
meaning of some of it; I bet there are docs somewhere in the world
that explain it). I would be inclined to experiment with simply
manipulating the lock and .seq files and writing the other two files
straight away.

Richard

Greg Laird wrote:

Hi Richard,
Thanks for your post. I am using the TCPIP print spooling routines so
I will not be using lpsrvr (though I like the idea of writing to
/dev/spool…). I also like your idea of spawning lpr and then
writing my data to a pipe. I think this is what I will do.

One question: I will generate a file for printing every few minutes
and would like the file to be spooled immediately after I have
completed writing it. The way I imagine this would work would be:

aa:
create pipe
spawn lpr and pass fd for read side of pipe
write my postscript data into write side of pipe
close my write side of the pipe when done with page
go to aa

I am guessing that lpr will not release the file to the spooler until
it reads and EOF on the file. The only way that I can send an EOF is
to close the writing end of the pipe.

When lpr receives an EOF, I also imagine that it will terminate so I
will have to respawn it for every file I write. I would be great to
not have to respawn this program repeatedly.

Any comments or ideas?

Thanks again,
Greg Laird

On Wed, 14 Mar 2001 20:36:37 -0500, “Richard R. Kramer”
rrkramer@kramer-smilko.com> > wrote:

You should be able to open a pipe, spwan lpr with “-P” and
“nec” args and write your file to the pipe.

If you also have lpsrvr running, there can be and entry in
/dev/spool/ that you can write to directly.

Richard

Greg Laird wrote:

Hello,
I am using QNX4.25 and have set up a remote printer using the TCPIP
based printer spooling system. I use lpr to print files. This all
works fine.

I have an application that generates postscript printer files and I
would like to spool these files from the application w/o the user
having to use lpr. I imagine that I could do this:

system(“lpr -P nec filename.ps”);

to print ‘filename.ps’ on the ‘nec’ printer. I was wondering if there
is a more elegant way to do this w/o calling a utility program. Maybe
I can send a message to a process or something?

If you have an idea and could point me in the direction of some
documentation that would be great!

Thanks for your time,
Greg Laird

On my QNX4 machine, there si no /dev/spool/ without lpsrvr; lpd
uses /usr/spool/… and there’s more to it that putting a file
there.

Richard

Andrew Thomas wrote:

Previously, Greg Laird wrote in qdn.public.qnx4:
Hi Richard,
Thanks for your post. I am using the TCPIP print spooling routines so
I will not be using lpsrvr (though I like the idea of writing to
/dev/spool…). I also like your idea of spawning lpr and then
writing my data to a pipe. I think this is what I will do.

Can you not use lpd instead of lpsrvr, and then write to the
/dev/spool file that lpd creates? Direct lpd to your networked
printer. Now all you have to do to print your file is:

  1. cat file to printer
    or
  2. open, write, close on the /dev/spool entry.

Cheers,
Andrew

I am somewhat hesitant to manipulate files to try to get it to work as
the software I am writing needs to work unattended and robustly.
Finding some docs regarding all of this would be the best bet.

My hunch is that somehow lpd must be prodded to process a file,
thereby adding it to its queue. Again, my guess would be that just
adding a file to the spool directory would not be enough–though I
don’t know this for sure. And maybe, if it worked once, it might not
work another time.

I wonder if there is a lpd expert around somewhere?

Best to you,
Greg


On Thu, 15 Mar 2001 13:47:18 -0500, “Richard R. Kramer”
<rrkramer@kramer-smilko.com> wrote:

I don’t know enough about the internals of lpr/lpd to give an
authoritative answer. Looking at the black-box behavior of lpd,
however, it appears that lpd looks in usr/spool/lpd/<printer
for pairs of files named a certain way. One file is the job to be
printed, the other is some housekeeping info (I can guess at the
meaning of some of it; I bet there are docs somewhere in the world
that explain it). I would be inclined to experiment with simply
manipulating the lock and .seq files and writing the other two files
straight away.

Richard

Greg Laird wrote:

Hi Richard,
Thanks for your post. I am using the TCPIP print spooling routines so
I will not be using lpsrvr (though I like the idea of writing to
/dev/spool…). I also like your idea of spawning lpr and then
writing my data to a pipe. I think this is what I will do.

One question: I will generate a file for printing every few minutes
and would like the file to be spooled immediately after I have
completed writing it. The way I imagine this would work would be:

aa:
create pipe
spawn lpr and pass fd for read side of pipe
write my postscript data into write side of pipe
close my write side of the pipe when done with page
go to aa

I am guessing that lpr will not release the file to the spooler until
it reads and EOF on the file. The only way that I can send an EOF is
to close the writing end of the pipe.

When lpr receives an EOF, I also imagine that it will terminate so I
will have to respawn it for every file I write. I would be great to
not have to respawn this program repeatedly.

Any comments or ideas?

Thanks again,
Greg Laird

On Wed, 14 Mar 2001 20:36:37 -0500, “Richard R. Kramer”
rrkramer@kramer-smilko.com> > wrote:

You should be able to open a pipe, spwan lpr with “-P” and
“nec” args and write your file to the pipe.

If you also have lpsrvr running, there can be and entry in
/dev/spool/ that you can write to directly.

Richard

Greg Laird wrote:

Hello,
I am using QNX4.25 and have set up a remote printer using the TCPIP
based printer spooling system. I use lpr to print files. This all
works fine.

I have an application that generates postscript printer files and I
would like to spool these files from the application w/o the user
having to use lpr. I imagine that I could do this:

system(“lpr -P nec filename.ps”);

to print ‘filename.ps’ on the ‘nec’ printer. I was wondering if there
is a more elegant way to do this w/o calling a utility program. Maybe
I can send a message to a process or something?

If you have an idea and could point me in the direction of some
documentation that would be great!

Thanks for your time,
Greg Laird