Launching an application from CUPS Backend

Mohit Kumar mohitkumar17 at yahoo.com
Sun Sep 4 23:26:51 PDT 2005


> Anonymous wrote:
> >
> > > Mohit Kumar wrote:
> > > >
> > > > Hi All,
> > > >
> > > > I am writing a backend for CUPS, which would finally print a pdf file. However, after printing I want to open this application in any PDF Viewer, say Adobe Reader.
> > > >
> > > > Is it possible for me to do so?
> > > >
> > > > I had tried to "execvp" Adobe Reader with the name of the file as the argument, but nothing happened. So I was wondering if there is something that can be done in this regard or some one has some mechanism to make this working.
> > > >
> > > > Any kind of help would be highly appreciated.
> > > >
> > > > Thanks,
> > > > Mohit
> > >
> > > You need to launch a process under the id of the user who requested the print operation.
> > > And, this will only be feasible if the CUPS server and the user's workstation is the
> > > same machine. If not, you almost certailny will run into trouble with remote execution
> > > and/or display access rights.
> > >
> > > Perhaps you can afford to wait for a stable CUPS 1.2 and then hook to the notification
> > > mechanism to launch your viewer at the client's side.
> > >
> > > Helge
> > >
> > > --
> > > Helge Blischke
> > > Softwareentwicklung
> > > SRZ Berlin | Firmengruppe besscom
> > > http://www.srz.de
> >
> > Hi Helge and all,
> >
> > I have been unable to open the application as suggested by you. The following is the code I have written:
> >
> > for(countParams=0; countParams<3 ;countParams++)
> >    commandLine[countParams]=NULL;
> > commandLine[0] = (char*)malloc(20*sizeof(char));
> > strcpy(commandLine[0],"xpdf");
> > commandLine[1] = (char*)malloc((strlen(outfile)+1)*sizeof(char));
> > strcpy(commandLine[1],outfile);
> > pid = vfork();
> > if(!pid)
> > {
> >         execvp(commandLine[0],commandLine);
> >         _exit(1);
> > }
> >
> > outfile is the name of the file being printed.
> >
> > What am I doing wring here?
> >
> > Moreover, are you aware of any API which would let me open the process with the credentials of the user who had requested the print? I have the knowledge of the user who had requested a print.
> >
> > Any kind of help would be highly appreciable.
> >
> > Thanks,
> > Mohit
>
> Be aware that xpdf needs the DISPLAY environment variable to be properly set
> (or the display specified by the -display foobar:x.y command line option).
> Otherwise it sill immediately terminate.
>
> Helge
>
> --
> Helge Blischke
> Softwareentwicklung
> SRZ Berlin | Firmengruppe besscom
> http://www.srz.de

Agreed Helge, but when I copy the above lines of code and put it in a different excutable it works, but not as a backend.

What I doubt is that does CUPS disable any kind of UI throw up from its backend?

Thanks,
Mohit




More information about the cups-devel mailing list