Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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_FILEWhen 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

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?

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

![]() |
![]() |
![]() |

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