[lug] bash -x script_to_debug
rm at mamma.varadinet.de
rm at mamma.varadinet.de
Sun Apr 1 04:43:30 MDT 2001
On Sun, Apr 01, 2001 at 03:11:20AM -0600, D. Stimits wrote:
> Bob Collins wrote:
> >
> > Is there a way to capture the output sent to the screen when
> > running a script like below?
> >
> > bash -x script_to_debug
> >
> > --
> > Regards, Bob Collins
> > Computers are useless. They can only give you answers.
> > -- Pablo Picasso
>
> The "tee" command is nice for this. For example, if it is just standard
> out (no standard error):
> bash -x script_to_debug | tee FileNameToLogTo.txt
Won't work like that. You'll only catch the output of
the script, _not_ the debugging messages of bash
which are sent to stderr (file descriptor 2).
You have two options:
- redirect the output of bash
bash -x script_to_debug 2>log.txt
- redirect both the output of bash as well
as the output of the script (and the error
messages of the script)
bash -x script_to_debug >log.txt 2>&1
- record the whole session with 'script'
$ script log.txt
Script started, file is log.txt
$ bash -x script_to_debug
+ ....
....
$ ^D
$ Script done, file is log.txt
If you don't give a filename to script it wil save
all output to the file 'typescript'. You need to
enter Ctr-D to stop script from recording the session.
Ralf
More information about the LUG
mailing list