From:	CSBVAX::MRGATE!info-vax-RELAY@KL.sri.com@SMTP  1-AUG-1988 17:35
To:	ARISIA::EVERHART
Subj:	Need help with sys$sndjbcw...


Received: from vx2.GBA.NYU.EDU ([128.122.130.85]) by KL.sri.com with TCP; Wed, 27 Jul 88 09:30:36 PDT
Received: by vx2.GBA.NYU.EDU (5.51/) id AA26218; Wed, 27 Jul 88 12:29:44 EDT
Date: Wed, 27 Jul 88 12:29:44 EDT
From: David HM Spector <spector@vx2.GBA.NYU.EDU>
To: info-vax@kl.sri.com
Subject: Need help with sys$sndjbcw...



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."
