Printing to CUPS printer via LPR fromEmbedded System

Ian ian.sanderson at gmail.com
Mon Feb 16 16:20:19 PST 2009


Hi Jon,

Thank you for your advice. Before I modify the cups-lpd.c file I have a quick question:

Is it possible that cups-lpd doesn't have sufficient rights to a temporary directory to store the incoming lpd control file? Is there a particular spot that cups-lpd will try to create the control file?

Thanks again.

Ian

> On Mon, 16 Feb 2009, Ian wrote:
>
> > Hello,
> >
> > I am trying to print to a CUPS printer from an embedded system that supports LPR. When I user a hardware print server (i.e. HP JetDirect) I can print fine, but when I try to use CUPS I get no printout. However, if I try to print from a windows machine to the CUPS printer using LPR it works fine.
> >
> > This is my /var/log/messages file after first trying to print from the embedded system and then printing from windows:
> >
> > *************************************
> > ---/var/log/messages---
> > Feb 14 14:04:13 haroldws08 syslogd 1.4.1: restart.
> > Feb 14 14:04:13 haroldws08 kernel: klogd 1.4.1, log source = /proc/kmsg started.
> > Feb 14 14:04:35 haroldws08 xinetd[8197]: START: printer pid=8239 from=192.168.2.201
> > Feb 14 14:04:35 haroldws08 cups-lpd[8239]: Connection from 192.168.2.201 (IPv4 192.168.2.201)
> > Feb 14 14:04:35 haroldws08 cups-lpd[8239]: Receive print job for PRINTER
> > Feb 14 14:04:36 haroldws08 cups-lpd[8239]: Error while reading file - No such file or directory
> > Feb 14 14:04:36 haroldws08 cups-lpd[8239]: Closing connection
> > Feb 14 14:04:36 haroldws08 xinetd[8197]: EXIT: printer status=1 pid=8239 duration=1(sec)
> > Feb 14 14:11:47 haroldws08 xinetd[8197]: START: printer pid=8363 from=192.168.2.158
> > Feb 14 14:11:47 haroldws08 cups-lpd[8363]: Connection from calws-20.barbereng.com (IPv4 192.168.2.158)
> > Feb 14 14:11:47 haroldws08 cups-lpd[8363]: Receive print job for printer
> > Feb 14 14:11:47 haroldws08 cups-lpd[8363]: Print file - job ID = 7
> > Feb 14 14:11:47 haroldws08 cups-lpd[8363]: Closing connection
> > Feb 14 14:11:47 haroldws08 xinetd[8197]: EXIT: printer status=0 pid=8363 duration=0(sec)
> > *************************************
> <snip>
> >
> > Any help you might be able to offer would be appreciated.
>
> You don't say which cups version you are using, but at least for
> cups-1.3.x the error message "Error while reading file -" is certainly
> from recv_print_job() in cups-lpd.c ie at about line 1050:
>
>     /*
>      * Copy the data or control file from the client...
>      */
>
>      for (i = atoi(count); i > 0; i -= bytes)
>      {
>        if (i > sizeof(line))
>          bytes = sizeof(line);
>        else
>          bytes = i;
>
>        if ((bytes = fread(line, 1, bytes, stdin)) > 0)
>          bytes = write(fd, line, bytes);
>
>        if (bytes < 1)
>        {
>  	syslog(LOG_ERR, "Error while reading file - %s",
>                 strerror(errno));
>          status = 1;
>  	break;
>        }
>      }
>
> so it is failing whiule reading the control-file or a data-file from the
> client.  After getting such an error it gives up on the request so it will
> never actually touch the cups daemon - so those logs are probably
> irrelevant.
>
> Why the fread() or write() is returning < 1 isn't clear, so perhaps adding
> some debugging at about that point will help - or at least tracing the
> cups-lpd process...
>
> Perhaps the lpd control file is 'bad' in some way which cups-lpd objects
> to - but the jetdirect implementation is more relaxed.
>
> I'd suggest changing that section to something like:
>
>     /*
>      * Copy the data or control file from the client...
>      */
>
>      syslog(LOG_ERR, "About to read file expected %s bytes", count);
>      for (i = atoi(count); i > 0; i -= bytes)
>      {
>        syslog(LOG_ERR, "In loop expecting %d more bytes", i);
>
>        if (i > sizeof(line))
>          bytes = sizeof(line);
>        else
>          bytes = i;
>
>        if ((bytes = fread(line, 1, bytes, stdin)) > 0)
>        {
>          syslog(LOG_ERR, "fread returned %d", bytes);
>          bytes = write(fd, line, bytes);
>          syslog(LOG_ERR, "fwrite returned %d", bytes);
>        } else {
>          syslog(LOG_ERR, "error fread returned %d", bytes);
>        }
>
>        if (bytes < 1)
>        {
>          syslog(LOG_ERR, "Error while reading file - %s",
>                 strerror(errno));
>          status = 1;
>          break;
>        }
>      }
>
> and seeing what logs that produces.
>
>   -- Jon
>





More information about the cups-devel mailing list