Re: leading null characters produced in script...




Your otherScript doesn't close the file, so it continues to write
at the position it was previously at.

The easiest solution is to move the redirection inside the script,
so that it will open and close the file whenever it needs to write
to the it, e.g.:

logfile=$1
exec 2>&1
while :
do
: whatever needs doing
printf "%s\n" result >> "$logfile"
done


Rather than:

while :
do
: whatever needs doing
printf "%s\n" result
done > "$logfile"


Call the first version with:

./otherScript "$logfile"


I think I understand what you're saying. There is only one
complication: The "otherScript" that I mentioned is considered a
script that I have no control over (Sure, since it is also a script I
can modify it...but preferably not, since this is considered, well, for
lack of a better word, "third-party" script). All it does is it does
some processing, and it prints processing info to stdout. The only way
to capture these is by redirection, hence "./otherScript >$logfile".

Unfortunately, $logfile tends to grow large if ./otherScript is set to
run, say, overnight. Hence, the external "log archiver" that I wrote.

Is there another way to reposition the file pointer when otherScript
writes to $logFile?

Also, Robert Hull mentioned the command "logrotate". I'm not familiar
with this command at all...I will read the man in a sec. But I'd still
like to find out and solve the situation I just described above....

.