Summary: scanf (atrun problem)

From: K. Bader (bader@nadc.nadc.navy.mil)
Date: Mon Dec 17 1990 - 12:04:13 CST


Thank you for all your responses. Now I know where to turn if I have
a problem I cannot resolve.

My original question:
--------------------

>Does anyone have or know of a patch for scanf. Or is anyone running
>"at" jobs on a Sun 3 running SunOS 3.5? Any help would be appreciated.

Solutions:
---------

The problem was not with scanf but with the structure of the fscanf statement
used in the atrun program. It was expecting characters other than \n
following the header and was therefore returning the error "bad spool header".
The same time I sent my letter I tried taking BSD source and changing the
fscanf statement. I figured I was reaching but it turns out to be a
legitimate solution. It works fine now. For those who do not have bsd source
you can edit the binary using GNU EMACS or just use a previous version of
/usr/lib/atrun (3.2 or 3.4). Thank you for all your responses. It was a
big help to know I wasn't too far in left field.

More details follow:
--------------------

From: Sven-Ove Westberg <sow@cad.luth.se>

I sent this to sunspots some years ago. If you don't have bsd source
take it as an exersice to patch the atrun binary with emacs.

> 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

It is a bug in the c-compiler, c-library or atrun. The problem is that
Suns scanf requires that it is atleast one character left to this
expession '%*[^\n]'. I include a diff from bsd4.3 atrun to fix this
problem.

------- atrun.c -------
*** /tmp/da8191 Tue Dec 13 09:02:45 1988
--- atrun.c Sun Oct 16 00:27:10 1988
***************
*** 177,186 ****
           * 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);
--- 177,186 ----
           * Grab the 4-line header out of the spoolfile.
           */
          if (
! (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);

From: Bill Randle <billr%saab.cna.tek.com@RELAY.CS.NET>

Here's the patch for atrun that fixes the problem:

--- Forwarded mail from Alexander Lopez <alexl@daemon.CNA>

Fortunately, the scanf's used can be patched, which is what I did. This then
assumes the header lines wont radically change, which they haven't yet.

So, heres the deal:

        #! /bin/csh
        cd /usr/lib
        cp atrun atrun.dist
        adb -w atrun << EOF
        200c8?w 0a00
        200e0?w 0a00
        200f4?w 0a00
        20111?w 0a00
        $q
        EOF

Thanks also to:
 Don Hooper <hoop@khonshu.Colorado.EDU>
 Svante Lindahl <zap@inmic.se>
 fpb@ittc.wec.com (Frank P. Bresz)
 paula@atc.boeing.com
 "alex;923-4483" <alexl%daemon.cna.tek.com@RELAY.CS.NET>
 fed!m1rcd00@uunet.UU.NET
 oconnor!porsche!miker@oddjob.uchicago.edu (Mike Raffety)



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:00 CDT