[comp.os.vms] Need help with sys$sndjbcw...

spector@VX2.GBA.NYU.EDU (David HM Spector) (07/27/88)

Help!  I need some advice from any job control gurus who may be around.

Here's what I am trying to do:  I am writing and lpd-like object that gets 
spawned by the MultiNet (or TWG) version of inetd.  The program listens on 
port 515 for print requests, just like lpd, etc.  Everything works OK until
I attempt to submit the job to the job controller for printing.  I am
using sys$sndjbcw(); the job controller doesn't return an error, but the 
job is never entered in the queue or printed.  The program runs as SYSTEM
and has no problems with privs.  A small test version of the program runs
fine when executed from a terminal, it only fails when run from from the 
server process...  

Any ideas?   I am stumped.  

Here are the declarations of the globals used in the routine that actually does
the submit to the job controller...

char qfileName[L_tmpnam+1],dfileName[L_tmpnam+1]; 
#define MAXNAMELEN	32
char userName[MAXNAMELEN] = "";
char sourceHost[MAXNAMELEN] = "";
char fileToPrint[MAXNAMELEN]= "";
char queueName[MAXNAMELEN] = "LPS40";       
char jobname[MAXNAMELEN] = "";
char parameter1[MAXNAMELEN] = "PAGE_ORIENTATION=PORTRAIT";
char parameter2[MAXNAMELEN] = "MESSAGES=PRINT";
char parameter3[MAXNAMELEN] = "DATA_TYPE=ANSI";

And this is the routine that does the work...
printit()
{                         
int result;
char *s,*s2;
struct { short len,code; char *ptr,*retlen;}
   sjcitm[] = {
      { 0, SJC$_QUEUE, queueName, 0},
      { 0, SJC$_FILE_SPECIFICATION, fileToPrint, 0},
      { 0, SJC$_NO_PAGINATE, 0, 0},
      { 0, SJC$_DELETE_FILE, 0, 0},
      { 0, SJC$_PARAMETER_1, parameter1, 0},
      { 0, SJC$_PARAMETER_2, parameter2, 0},
      { 0, SJC$_PARAMETER_3, parameter3, 0},
      { 0, SJC$_JOB_NAME, jobname, 0},
      { 0, SJC$_USERNAME, userName, 0},     
      {0,0}};           
                                                       

	/* Queue Name */
	sjcitm[0].len = strlen(queueName);
	/* Filename */                  
	/* Pascal's CONCAT would be nice here.... (*Sigh*) */
	s = strcat("LPDSPOOL:", dfileName);
	s2 = strcat(s, ".;");        

  	strcpy(fileToPrint, s2);    
	sjcitm[1].len = strlen(fileToPrint);
	/* Parameters */
	sjcitm[4].len = strlen(parameter1);
	sjcitm[5].len = strlen(parameter2);
	sjcitm[6].len = strlen(parameter3);	
 	/* copy the job name obtained from the control file */
	sjcitm[7].len = strlen(jobname);
	/* copy the username obtained from the control file */
	sjcitm[8].len = strlen(userName); 
/*	...and, Submit the file to the system job controller for printing.*/

	result = sys$sndjbcw(0, SJC$_ENTER_FILE, 0, sjcitm, diosb, 0, 0);
} /* of print it */                            
                                               
-------------------------------------------------------------------------------
David HM Spector				New York University
Senior Systems Programmer			Graduate School of Business
Arpa: SPECTOR@GBA.NYU.EDU			Academic Computing Center
UUCP:...!{allegra,rocky,harvard}!cmcl2!spector	90 Trinity Place, Rm C-4
HamRadio: N2BCA      MCIMail: DSpector          New York, New York 10006
AppleLink: D1161     CompuServe: 71260,1410     (212) 285-6080
"What computer puts out work like this?"  "Hire us and we'll tell you."

laidlaw@orion.rutgers.edu (08/03/88)

In article <8808022020.AA10361@ucbvax.berkeley.edu>, spector@VX2.GBA.NYU.EDU (David HM Spector) writes...
 
> 
> 
>Help!  I need some advice from any job control gurus who may be around.
> 
>Here's what I am trying to do:  I am writing and lpd-like object that gets 
>spawned by the MultiNet (or TWG) version of inetd.  The program listens on 
>port 515 for print requests, just like lpd, etc.  Everything works OK until
>I attempt to submit the job to the job controller for printing.  I am
>using sys$sndjbcw(); the job controller doesn't return an error, but the 
>job is never entered in the queue or printed.  The program runs as SYSTEM
>and has no problems with privs.  A small test version of the program runs
>fine when executed from a terminal, it only fails when run from from the 
>server process...  
> 
>Any ideas?   I am stumped.  
> [more stuff deleted]


	This is A fussy call make sure that the detatched process
actually has CMKRNL turned on.  If not it will fail silently or
at least has on my VMS 4.4 system.  

						Good Luck
						Angus
	laidlaw@orion.rutgers.edu
	laidlaw@cancer.bitnet
	Real soon now: laidlaw@draco.rutgers.edu
		       laidlaw@draco.bitnet

	PS: I would be interested in a copy of your program when you
		get it working.  We are working on a print symbiont that
		will send jobs via lpr and will be implementing the 
		receiver soon.