Redirection of logging to file & screen

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
huijstee [ Di, 08 Januar 2008 00:18 ] [ ID #1902402 ]

Re: Redirection of logging to file & screen

In article
<0752b97b-1a76-446b-868f-d7c61218cf6f [at] q39g2000hsf.googlegroups.com>,
huijstee [at] 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 [at] 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 ***
Barry Margolin [ Di, 08 Januar 2008 04:44 ] [ ID #1902408 ]

Re: Redirection of logging to file & screen

huijstee [at] 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.
Ed Morton [ Di, 08 Januar 2008 05:42 ] [ ID #1902414 ]
Linux » comp.unix.shell » Redirection of logging to file & screen

Vorheriges Thema: Comparing two strings (one may be a null)
Nächstes Thema: newbie script help: script to check file mod date