Re: leading null characters produced in script...




Easy fix. Change your redirection to _append_ to the log file:

./otherScript >>$logfile

When a file is opened in append mode, there is an implied seek to EOF
before every write(2) call. Now, when your log rotation truncates the
file to zero length, the next write will seek to offset 0 instead of
continuing at its current (large) offset.

--
Bob Nichols AT comcast.net I am "RNichols42"

Nope that does not work. I just tried it and leading nulls are still
there....

Regardless, thanks for all your input and all the responses. I finally
got it to work after understanding the underlying problem that by not
closing the file, ./otherScript is still writing at the same file
position pointer even after the content that its written before are
moved over.

So after all the thread, the solution I went with is Chris F.A.
Johnson's recommendation by moving the redirection inside the script.
As it turns out, I have some liberty in changing ./otherScript after
all, which makes it easier to control the output redirection
(technically, the "third-party" entity that I really can't modify is
the binary that is being called INSIDE ./otherScript, and this is the
one that is spitting out the log information.

Anyway, very interesting. I'm learning new stuff every day :D

.