Configuring the screen command to always output to a log file (screen dump file)

Hello I am a server support analyst for some RHAS3 linux servers.

I like to use the "screen" command to mirror standard output from an IBM UniData database, UniBasic program to a logfile. Everything that is normally sent to STDOUT is then also sent to the screen logfile. I can then monitor the contents of the logfile with a Perl script and do all sorts of things like email notifications.

How do I configure "screen" so that it starts writing to the screen logfile immediately after I have typed "screen<enter>"? In order to start writing to the log I am forced to press CTRL-A H but I want to avoid having to do this.

I have already tried configuring screen to always output to a logfile for root but my configuration does not seem to work even though it is configured according to the man page. (Or is it?)

I have configured my ~root/.screenrc as follows:

logfile /usr/local/scripts/fixtransp/screen.dump
logfile flush 3
log on

But when I log in as root then type "screen<enter>" the logfile does not get updated until I press CTRL-A H (case-sensitive).

Note: fixtransp is the dir of a script I'm writing to examine the screen.dump logfile and do some nice things.

Many Thanks In Advance

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use "deflog on" instead of "log on".

Note that right after you start "screen" today, you see a little note at the butotom of the screen saying something like "log: window required". That's because you've turned on logging, before there was an active window.
deflog sets logging by default to all windows, so that solves the problem.

You would expect that if you would use the "select" command before the "log" command it would work, but it doesn't. Have no idea why. The ways of screen are mystirious indeed... :-)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
juggling2Author Commented:
Thanks that works great!

I also found out that when starting screen, "screen -L" also does the same thing.

I shoulda read the manual more thoroughly :)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.