[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dbootstrap: system and err msgs



> Massimo Dal Zotto <dz@cs.unitn.it> writes:
> 
> > Maybe this should be done explicitly on a command basis rather than have
> > a system wrapper which redirect all outputs to stderr, otherwise we can't
> > redirect the error output of the various commands included in the busybox
> > executable.
> 
> That's not true.  I don't think there are any commands around which
> require that stderr be redirected to a script which reads it.

Error redirection is a basic feature which should be available on every
unix system for every `well-bahaved' command. If you redirect to /dev/tty3
or syslog all the error messages of all the commands aliased to busybox you
will get a set of commands which don't follow the basic unix principles, i.e.
they don't print errors to stderr.

I often use this feature in my scripts to capture error messages and process
them in some automatic way. Only in my automatic installer scripts, which uses
busybox and all its aliases, I have counted 19 occurrences of "some_cmd 2>&1".
I assume that also many other programmers use this basic thecnique. 

The fact that you don't intend to use stderr in your bootfloppy doesn't seem
to me a good reason to change error handling in that way, as you will prevent
anyone using busybox and any of its commands for other purpose than the debian
installation.

If you want to redirect all error messages you should at least use a new
switch, disabled by default, or an enviromnent variable to control this
feature. The enviromnent variable is a dirty and quick way to do it but it
works almost always and won't break any existing program.

> > Why don't just start dbootstrap with:
> > 
> >     exec dbootstrap 2>/dev/tty3
> 
> I don't know if that would work or not.  Anyhow, Erik is adding basic
> syslog facilities to busybox so we're going to use that (also
> reproducing log msgs on tty3 for non-serial-console), which is a
> better solution.

My suggestion works. You can replace the original dbootstrap command with a
shell script like this:

    #!/bin/sh
    stty sane </dev/tty3
    exec real_dbootstrap "$@" 2>/dev/tty3

or with this other using the enviromnent variable trick:

    #!/bin/sh
    REDIRECT_STDERR=syslod		# This could be /dev/tty3 or empty
    exec real_dbootstrap "$@"

In this way you can redirect errors of dbootstrap and all the other commands
spawned by it without removing the stderr messages from all the other busybox
aliases.

> We'll still need a generic function that runs system, redirecting
> stderr to syslog...

I don't understand why complicate things when there is an easier an standard
way to do the same.

-- 
Massimo Dal Zotto

+----------------------------------------------------------------------+
|  Massimo Dal Zotto               email: dz@cs.unitn.it               |
|  Via Marconi, 141                phone: ++39-0461534251              |
|  38057 Pergine Valsugana (TN)      www: http://www.cs.unitn.it/~dz/  |
|  Italy                             pgp: finger dz@tango.cs.unitn.it  |
+----------------------------------------------------------------------+


Reply to: