Article View: comp.mail.mush
Article #302Mush 'cron' enabling patch
From: Tom Neff
Date: Tue, 12 Dec 1989 18:29
Date: Tue, 12 Dec 1989 18:29
54 lines
2154 bytes
2154 bytes
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
Technical Details
Message-ID:
<14991@bfmny0.UU.NET>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!bfmny0!tneffShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!bfmny0!tneff From: tneff@bfmny0.UU.NET (Tom Neff) Newsgroups: comp.mail.mush Subject: Mush 'cron' enabling patch Summary: allows non-tty stdin if -F! flag set Message-ID: <14991@bfmny0.UU.NET> Date: 12 Dec 89 18:29:23 GMT Reply-To: tneff@bfmny0.UU.NET (Tom Neff) Lines: 54