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
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.
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).
Summary: I have found out that some code I am working on could be made simpler and neater by writing files to new streams created by me, and then later reading from those new streams line by line in a loop. Th...
Summary: "true" is standard ksh, and means the same as ":" nohup hello & ulimit -f 0 has me puzzled though. You nohup "hello" (= start your server process?) in background, but where does "ulimit -f 0" come in?...
Summary: Hello, How do you write a file to a log file? and what kind of information should we write to it, say for example i want to delete a core file and write it to this log file. thanks ...