Computing.Net > Forums > Unix > Writing to logfile and stdout

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Writing to logfile and stdout

Reply to Message Icon

Name: Mondoshiva
Date: November 23, 2004 at 01:17:37 Pacific
OS: UNIX AIX
CPU/Ram: 1GB
Comment:

Hi all,

is there a way to simultaneous writing to a logfile and to stdout?

i don't want to use TEE.

the problem is that i open a xterm with option -e to start another process. the output of this process gets to the stdout of the xterm. when the process is finished (it takes up to one hour!) i want to go through the logfile to check for errors but i also want to have the output on the screen.
Also tail -f is not what i want because when the process is finished i want to ask for some entries before i finish the xterm.

thanks a lot for your help.




Sponsored Link
Ads by Google

Response Number 1
Name: thepubba
Date: November 23, 2004 at 17:47:48 Pacific
Reply:

Is there a reason you couldn't do something like:

print $msgLine
print $msgLine >> logfile

The first would print to stdout and the second would print to your log file.

Am I missing something?


0

Response Number 2
Name: cbailey33
Date: November 28, 2004 at 20:09:36 Pacific
Reply:

You can also use "tee". This will put the output in the file and send the results to SDTOUT.

example:

df -kl | tee myfile


0

Response Number 3
Name: thepubba
Date: November 30, 2004 at 20:49:45 Pacific
Reply:

Craig:

Did you perhaps not notice that the poster indicated the did NOT want to use tee?


0

Response Number 4
Name: Mondoshiva
Date: December 6, 2004 at 03:28:53 Pacific
Reply:

Hi,
thanks to all for your answer and sorry for my late reply. i was on vacation.

The resason why i can't do
print $msg
print $msg >> logfile
is that i start another automated process which writes to stdout. Unfortunatelly is it not possible to modify this process to write to stdout and logfile.

Maybe somebody knows a perl script or something else which handels the logging process better than UNIX itself does.

Cheers,
Mondoshiva


0

Response Number 5
Name: cdac1000
Date: December 29, 2004 at 15:02:08 Pacific
Reply:

may be you want to try this one.

in your script add this to the begining

LOG=/tmp/process.log

exec 2>$LOG

2 (STDERR) here is used to collect all the errors. by default
any process running puts output on 1 (STDOUT).


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon

Using AWK weeknumber out of given d...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Writing to logfile and stdout

Writing to/reading from 3, 4 etc. www.computing.net/answers/unix/writing-toreading-from-3-4-etc/7388.html

write log in loop - ksh script www.computing.net/answers/unix/write-log-in-loop-ksh-script/4721.html

writing to Log files www.computing.net/answers/unix/writing-to-log-files/6124.html