[comp.mail.mush] Mush 'cron' enabling patch

tneff@bfmny0.UU.NET (Tom Neff) (12/13/89)

I wanted to run a Mush 6.5.6 script nightly in my crontab, but when I
tried the following setup on my Sys V/386 3.2:

-----------------------------------------------------
	# crontab entry
	45 02 * * * bin/purgemail
-----------------------------------------------------
	# purgemail script

	Tmpf=/tmp/pms.$$

	cat <<- EOF > $Tmpf
		pick -ago -8d | delete
		quit
	EOF

	/usr/local/bin/mush -noinit -f Mailsave -F! $Tmpf

	rm -f $Tmpf
-----------------------------------------------------

I got a message from Mush saying "you can't redirect input unless you're
sending mail."  Turns out main.c checks isatty(0) which fails under
cron.  Yet the restriction is pointless under -F! (source-and-exit) if
the script is properly written.

So I patched main.c to allow a non-tty stdin if -F! is set.  It works.

------- cut here ------- cut here ------- cut here ------- cut here 

*** main.c.old	Tue Aug  8 15:49:58 1989
--- main.c	Tue Dec 12 13:17:43 1989
***************
*** 199,205 ****
      }
      turnoff(glob_flags, IS_SENDING); /* no longer sending mail; running shell */
  
!     if (ison(glob_flags, REDIRECT)) {
  	puts("You can't redirect input unless you're sending mail.");
  	puts("If you want to run a shell with redirection, use \"-i\"");
  	cleanup(0);
--- 199,206 ----
      }
      turnoff(glob_flags, IS_SENDING); /* no longer sending mail; running shell */
  
!     if (ison(glob_flags, REDIRECT)
! 		&& (!Flags.src_file || !Flags.src_n_exit)) {
  	puts("You can't redirect input unless you're sending mail.");
  	puts("If you want to run a shell with redirection, use \"-i\"");
  	cleanup(0);

-- 
'The Nazis have no sense of humor, so why   -|  Tom Neff
should they want television?' -- Phil Dick  |-  tneff@bfmny0.UU.NET