On Tue, Jun 22, 2010 at 02:49:13PM -0700, Jeremy Allison wrote:
> On Tue, Jun 22, 2010 at 05:37:08PM -0400, Eric Rowell wrote:
> > Tried the following after poking around:
> > 
> > rpcclient -c "setjob printer  1340 job_control_cancel" -U username 
> > PrinterServer
> > 
> > rpcclient -c "setjob printer  1340 job_control_delete" -U username 
> > PrinterServer
> > 
> > It doesn't error but it didn't cancel or delete the job.
> 
> The "setjob" function uses a numeric job control code
> (which sucks, I know :-).
> 
> So you need to do the following :
> 
>         SPOOLSS_JOB_CONTROL_PAUSE=(int)(1),
>         SPOOLSS_JOB_CONTROL_RESUME=(int)(2),
>         SPOOLSS_JOB_CONTROL_CANCEL=(int)(3),
>         SPOOLSS_JOB_CONTROL_RESTART=(int)(4),
>         SPOOLSS_JOB_CONTROL_DELETE=(int)(5),
>         SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER=(int)(6),
>         SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED=(int)(7),
>         SPOOLSS_JOB_CONTROL_RETAIN=(int)(8),
>         SPOOLSS_JOB_CONTROL_RELEASE=(int)(9)
> 
> rpcclient -c "setjob printer  1340 5" -U username PrinterServer
> 
> for job control delete.

Here's a patch (that applies to 3.5.x) that
makes this a little nicer to use.

Jeremy.
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 39c581c..0341b93 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -2724,6 +2724,33 @@ done:
 /****************************************************************************
 ****************************************************************************/
 
+static struct {
+       const char *name;
+       enum spoolss_JobControl val;
+} cmdvals[] = {
+       {"PAUSE", SPOOLSS_JOB_CONTROL_PAUSE},
+       {"RESUME", SPOOLSS_JOB_CONTROL_RESUME},
+       {"CANCEL", SPOOLSS_JOB_CONTROL_CANCEL},
+       {"RESTART", SPOOLSS_JOB_CONTROL_RESTART},
+       {"DELETE", SPOOLSS_JOB_CONTROL_DELETE},
+       {"SEND_TO_PRINTER", SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER},
+       {"EJECTED", SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED},
+       {"RETAIN", SPOOLSS_JOB_CONTROL_RETAIN},
+       {"RELEASE", SPOOLSS_JOB_CONTROL_RELEASE}
+};
+
+static enum spoolss_JobControl parse_setjob_command(const char *cmd)
+{
+       int i;
+
+       for (i = 0; i < sizeof(cmdvals)/sizeof(cmdvals[0]); i++) {
+               if (strequal(cmdvals[i].name, cmd)) {
+                       return cmdvals[i].val;
+               }
+       }
+       return (enum spoolss_JobControl)atoi(cmd);
+}
+
 static WERROR cmd_spoolss_set_job(struct rpc_pipe_client *cli,
                                  TALLOC_CTX *mem_ctx, int argc,
                                  const char **argv)
@@ -2737,11 +2764,13 @@ static WERROR cmd_spoolss_set_job(struct 
rpc_pipe_client *cli,
 
        if (argc != 4) {
                printf("Usage: %s printername job_id command\n", argv[0]);
+               printf("command = [PAUSE|RESUME|CANCEL|RESTART|DELETE|"
+                       "SEND_TO_PRINTER|EJECTED|RETAIN|RELEASE]\n");
                return WERR_OK;
        }
 
        job_id = atoi(argv[2]);
-       command = atoi(argv[3]);
+       command = parse_setjob_command(argv[3]);
 
        /* Open printer handle */
 
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba

Reply via email to