On Wed, Dec 15, 2010 at 4:57 AM, Ian Smith <[email protected]> wrote:
> In freebsd-questions Digest, Vol 341, Issue 3, Message: 17 > On Tue, 14 Dec 2010 19:02:54 +0100 Samuel Mart?n Moro <[email protected]> > wrote: > > Hi, > > > > I'm adding some scripts to FreeBSD boot. > > One of this script runs a binary that checks our postgres database, its > > output being redirected to a dialog --gauge. > > But I noticed that the dialog output, while correctly displayed on the > > terminal, is also dumped into /var/log/console.log and > /var/log/messages. > > > > I'm not even sure about how this is happening... I can't find about > messages > > nor console.log in /etc/rc* > > As you indicate below, 'tty is /dev/console' while running the boot rc > scripts, so it's normal to see these scripts logged to console.log when > that's ebabled .. presumably /etc/syslog.conf includes something like: > # uncomment this to log all writes to /dev/console to /var/log/console.log > console.info /var/log/console.log > indeed it does. > > > Is there a way to disable log output in a given rc.script? > > > > here's my script: > > #!/bin/sh > > [...] > > test "$1" = 'start' -o "$1" = 'faststart' || exit 0 > > Prg=`basename $_file` > > exec 2>/var/log/$Prg.log > > You're redirecting stderr to your logfile, but not stdout, so standard > output from the below goes to /dev/console, so also to /console.log > > > test "$TERM" || export TERM=cons25 > > DIALOG="/usr/local/bin/dialog --no-collapse --cr-wrap --colors" > > echo "tty is `tty`" >&2 #debug, prints: tty is /dev/console > > echo "===== Checking DB 1/2 =====" >&2 > > The above line is also written to stdout, so to console.log below, so > I'm not sure whether your exec usage | syntax | redirection is correct. > it is dialog is used to display menus using curses during the boot process, everything "looks" fine (except for logs), menus are correctly displayed, while processing the DB scan. > > > dbcheck -s | $DIALOG --gauge "\n Checking DB 1/2" 7 70 > 2>/dev/null > > echo "===== Checking DB 2/2 =====" >&2 > > dbcheck -r -s | $DIALOG --gauge "\n Checking DB 2/2" 7 70 > 2>/dev/null > > [...] > > > > here is what it gives in /var/log/messages: > > Dec 14 13:26:46 camtrace13 dhclient: New Subnet Mask (wlan0): > 255.255.255.0 > > Dec 14 13:26:46 camtrace13 dhclient: New Broadcast Address (wlan0): > > 192.168.0.255 > > Dec 14 13:26:46 camtrace13 dhclient: New Routers (wlan0): 192.33.160.111 > > Dec 14 13:26:47 camtrace13 kernel: m ^[[36m^[[44m^[[K^[[16;6H^[[1K > > ^[[30m^[[40m^[[70X^[[77`^[[36m^[[44m^[[K^[[13;9H^[[39;49m^[[m > > Dec 14 13:26:48 camtrace13 kernel: m ^[[36m^[[44m^[[K^[[16;6H^[[1K > > ^[[30m^[[40m^[[70X^[[77`^[[36m^[[44m^[[K^[[13;9H^[[39;49m^[[m > > I don't know why those two dialog lines are sent to /var/log/messages; > perhaps they indicate some error, only those being logged with *.notice? > this lines are mostly color code, used to display a grey window with a gauge, on a blue background. > > [..] > > > and here is what I can read in /var/log/console.log: > > Dec 14 13:26:43 camtrace13 kernel: Starting apache. > > Dec 14 13:26:46 camtrace13 kernel: Starting pgsql. > > If you view these scripts you'll see that they don't themselves write to > stdout .. it's the rc system logging these. > indeed, I noticed yesterday that "Starting ${name}" is part of rc.subr > > > Dec 14 13:26:47 camtrace13 kernel: ^[[m > > Dec 14 13:26:47 camtrace13 kernel: ^[[39;49m^[[=1S > > Dec 14 13:26:47 camtrace13 kernel: > > > ^[[39;49m^[[m^[[H^[[J^[[17d^[[36m^[[44m^[[1m^[[J^[[H^[[K^[[B^[[K^[[B^[[K^[[B^[[K^[[B^[[K^[[B^[[K^[[B^[[K^[[B^[[K^[[B > * > ^[[37m^[[**47m谀哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪** > 哪哪哪哪哪哪哪腲[[m^[[30m^[[47m縙[[m^[[**36m^[[44m^[[1m^[[K^[[B* > err.. we may have a encoding problem. but I'm quite sure it only is clearscreen, colors, and tputs stuff > > ^[[37m^[[47m砠[[m^[[30m^[[47m^[[68X^[[74`砠[[m^[[30m^[[40m^[[1m > > ^[[36m^[[44m^[[K^[[B ^[[37m^[[47m砠[[m^[[30m^[[47m Checking DB > > 1/2^[[20X^[[74`砠[[m^[[30m^[[40m^[[1m ^[[36m^[[44m^[[K^[[B > [..] > > Dec 14 13:26:48 camtrace13 kernel: Starting slim. > > Dec 14 13:26:48 camtrace13 kernel: Starting > > You'll need to rework this somehow so dialog's stdout isn't written to > /dev/console, though that may seem necessary if you want it coming up on > the VTY0 boot screen. It may involve decoupling this task from running > 'inline' as a boot script somehow, or else making sure that output is > redirected to a log or temporary file instead of directly into dialog. > mmmmkay. It's now fixed. OUT=`/sbin/conscontrol | /usr/bin/sed -n 's;^Configured: .*\(tty[^, ]*\).*$;/dev/\1;p'` (is it always /dev/ttyv0? in doubt, I'll trust conscontrol) [...] $DIALOG [...] >$OUT > > > dhclient and oss seem to dump their output in /var/log/messages, while > > apache, postgresql and slim dump their one in /var/log/console.log > > So... How can my rc.script write in both console and messages logs? > > And how can I get rid of that? > > dhclient's (running) output is normally logged to messages, whereas the > 'Starting' messages are output of the rc process as it launches things. > Indeed, my bad. > > And it's only those couple of lines to messages, the rest of them to > console.log is unsurprising and expected if they're written to stdout. > > HTH a bit, Ian Thanks! -- Samuel Martín Moro {EPITECH.} tek5 CamTrace S.A.S (+033) 1 41 38 37 60 1 Allée de la Venelle 92150 Suresnes FRANCE "Nobody wants to say how this works. Maybe nobody knows ..." Xorg.conf(5) _______________________________________________ [email protected] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[email protected]"
