Computing.Net > Forums > Unix > Two scripts pipe to a log file

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.

Two scripts pipe to a log file

Reply to Message Icon

Name: LeeCS
Date: August 5, 2002 at 20:00:16 Pacific
Comment:

Hi,

I'm having problem writing to a log file. Appreciate if anyone can help.

I'm running an application thru a script ("A") with input and output file as

/opt/bin/appl $OUTPUT_FILE &

from there I can issue command to "appl" by appending the command to $INPUT_FILE and obtain the output from $OUTPUT_FILE (the "command" which input to the $INPUT_FILE will also be shown to the $OUTPUT_FILE).

Now, in a NEW script ("B"), I want to write direct to $OUTPUT_FILE and $INPUT_FILE by doing

echo `date` >> $OUTPUT_FILE
echo "command1" >> %INPUT_FILE

When I tail the $OUTPUT_FILE, either the "date" or the "command1" is truncated or not in $OUTPUT_FILE at all. Why is that so?

rgds
CS




Sponsored Link
Ads by Google

Response Number 1
Name: Jerry Lemieux
Date: August 7, 2002 at 15:25:10 Pacific
Reply:

First off, you are not using a pipe. You are using redirection. The only possible cause I can think of is that your original process still has an open file descriptor on $OUTPUT_FILE and your redirection from script B is getting truncated by data being written by script A. Is script A still running when you start script B? I cannot reproduce your problem, although I tried by printing in a tight loop to a file and then runnng a command with redirection to that same file. Had no problem. Also, don't you mean $INPUT_FILE, not %INPUT_FILE?


0

Response Number 2
Name: Leecs
Date: August 12, 2002 at 02:23:57 Pacific
Reply:

Hi Jerry,

I'm not sure whether the original process has an open file descriptor on $OUTPUT_FILE, how to check that? But script A is definately running even script B is started.

If let us assume that the file descriptor is still openned for $OUTPUT_FILE, can I still redirect to this file?

* sorry for the wrong definition & the typo :p

thanks,
CS


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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: Two scripts pipe to a log file

How to keep the log file a fixed size www.computing.net/answers/unix/how-to-keep-the-log-file-a-fixed-size/2436.html

Start & End time of a log file www.computing.net/answers/unix/start-amp-end-time-of-a-log-file/6935.html

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