*BSD News Article 50862


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.uwa.edu.au!classic.iinet.com.au!news.uoregon.edu!newsfeed.internetmci.com!news.mathworks.com!fu-berlin.de!news.belwue.de!News.Uni-Marburg.DE!news.th-darmstadt.de!fauern!news.tu-chemnitz.de!irz401!uriah.heep!bonnie.heep!not-for-mail
From: j@bonnie.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Crontab and the % character
Date: 8 Sep 1995 16:23:02 +0200
Organization: Private U**x site, Dresden.
Lines: 38
Message-ID: <42pjk6$i9n@bonnie.tcd-dresden.de>
References: <marcus.225.0201FF80@ccelab.iastate.edu>
Reply-To: joerg_wunsch@uriah.heep.sax.de
NNTP-Posting-Host: 192.109.108.139
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

Marcus I. Ryan <marcus@ccelab.iastate.edu> wrote:
>I am running a Cron job using Crontab.  The problem:
>
>I issue the command - stathtml `date +"%B %b"`
>If I use the %'s by themselves then it interprets them as special control
>characters, but if I put a \ in front of each, the command is interpreted
>literally (i.e. "\%B \%b").  Since \ is apparently not working quite right, is
>there a different character I'm supposed to be using?  I look in man cron and
>man crontab but neither even mentioned the problem.

Which version of cron are you using?  I've just extracted the lines
from do_command.c and wrapped them with some simple i/o logic into a
separate program, and it appears that everything works fine in the
version that's in 2.0.5.  The only thing that's missing is an
opportunity to have a single backslash in the command line (either,
the backslash is followed by a % character, in which case it is being
suppressed, or it will be passed literally along with its succeeding
character).  This patch might fix this (two adjacent backslashes are
being passed as a single one):

--- do_command.c.orig	Fri Sep  8 14:37:36 1995
+++ do_command.c	Fri Sep  8 16:16:25 1995
@@ -283,7 +283,7 @@
 		 */
 		while (ch = *input_data++) {
 			if (escaped) {
-				if (ch != '%')
+				if (ch != '%' && ch != '\\')
 					putc('\\', out);
 			} else {
 				if (ch == '%')

The source directory is /usr/src/usr.sbin/cron/cron/.
-- 
cheers, J"org                      private:   joerg_wunsch@uriah.heep.sax.de
                                   http://www.sax.de/~joerg/

Never trust an operating system you don't have sources for. ;-)