at and atrun

Jim Easton jim at alberta.uucp
Fri Dec 30 16:57:47 AEST 1988


felix at ai.sri.com (Francois Felix INGRAND) writes:
> I have a problem running at and atrun on our sun3 under Sun UNIX 4.2
> Release 3.5 
> 
> the script is never executed, and when I run atrun by hand, I get an error:
> like this one:
> 88.334.0000.09: bad spool header
> 88.335.1105.48: bad spool header

We had the same problem with atrun.

The cause of its not working is a bug in fscanf.  There were 4 read
statements in atrun as follows;

	/*
	 * Grab the 4-line header out of the spoolfile.
	 */
	if (
	    (fscanf(infile,"# owner: %127s%*[^\n]\n",owner) != 1) ||
	    (fscanf(infile,"# jobname: %127s%*[^\n]\n",jobname) != 1) ||
	    (fscanf(infile,"# shell: %3s%*[^\n]\n",shell) != 1) ||
	    (fscanf(infile,"# notify by mail: %3s%*[^\n]\n",mailvar) != 1)
	    ) {
		fprintf(stderr, "%s: bad spool header\n", spoolfile);
		exit(1);
	}

The intent was to read a string from the line and then flush the line to
the line feed however there was nothing to flush (ie. the next character
was a <LF> and it did not flush it.  The next read got the line feed
instead of the next line as it was meant to and it declared an error.

Since we don't have the source for fscanf our fix was to remove the flush
- as follows;

	/*
	 * Grab the 4-line header out of the spoolfile.
	 */
	if (							/* UofA001 */
	    (fscanf(infile,"# owner: %127s\n",owner) != 1) ||
	    (fscanf(infile,"# jobname: %127s\n",jobname) != 1) ||
	    (fscanf(infile,"# shell: %3s\n",shell) != 1) ||
	    (fscanf(infile,"# notify by mail: %3s\n",mailvar) != 1)
	    ) {
		fprintf(stderr, "%s: bad spool header\n", spoolfile);
		exit(1);
	}

Jim Easton (..!alberta!jim)



More information about the Comp.sys.sun mailing list