Redirection of logging to file & screen
am 08.01.2008 00:18:17 von huijstee
Hi,
For redirecting STDOUT & STDERR to both screen and logfile, I use the
following method :
tee {logfile} >/dev/tty |&
exec 1>&p 2>&1
This works fine for non-interactive scripts. But when I use this in an
interactive script, the user input (STDIN goten from the terminal)
does not go into the logfile, but is displayed on screen.
Can anyone tell me what to set in order for STDIN to be displayed on
the terminal and to go into the log file?
Thanks in advance.
Mark
Re: Redirection of logging to file & screen
am 08.01.2008 04:44:55 von Barry Margolin
In article
<0752b97b-1a76-446b-868f-d7c61218cf6f@q39g2000hsf.googlegroups.com>,
huijstee@hotmail.com wrote:
> Hi,
>
> For redirecting STDOUT & STDERR to both screen and logfile, I use the
> following method :
>
> tee {logfile} >/dev/tty |&
> exec 1>&p 2>&1
>
> This works fine for non-interactive scripts. But when I use this in an
> interactive script, the user input (STDIN goten from the terminal)
> does not go into the logfile, but is displayed on screen.
>
> Can anyone tell me what to set in order for STDIN to be displayed on
> the terminal and to go into the log file?
There's no automatic way to do this that I know of. You're redirecting
output, the user's typing is input. It's only being seen because of the
terminal driver's echoing, it's not actually being written to stdout.
Why don't you run your application under script to log everything?
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Re: Redirection of logging to file & screen
am 08.01.2008 05:42:13 von Ed Morton
huijstee@hotmail.com wrote:
> Hi,
>
> For redirecting STDOUT & STDERR to both screen and logfile, I use the
> following method :
>
> tee {logfile} >/dev/tty |&
> exec 1>&p 2>&1
>
> This works fine for non-interactive scripts. But when I use this in an
> interactive script, the user input (STDIN goten from the terminal)
> does not go into the logfile, but is displayed on screen.
>
> Can anyone tell me what to set in order for STDIN to be displayed on
> the terminal and to go into the log file?
>
>
> Thanks in advance.
>
> Mark
You'd need to run an external tool like "screen", "script" or "hrdcpy"
which log the user input and tool output.
Ed.