Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Redirection + flush?



On Jan 26,  6:09pm, Vincent Lefevre wrote:
} Subject: Redirection + flush?
}
} I have several programs running on several machines and I want
} to redirect the error messages (from stderr) to a single file
} client.err via NFS with "2>>". Is there a way to ask zsh to do
} what need be so that the data are not corrupted?

The short answer is, no.  Once zsh opens the file descriptor and passes
it as the command's standard error, what the command does with it is
completely out of zsh's control.

The longer answer is that it's nearly impossible to do what you ask in
any case.  Unless the NFS filesystems are mounted with both the "hard"
and "sync" options, you have no hope of correctly interleaving output
from several different machines.  Even with those options set, NFS is
not a reliable protocol for multiple simultaneous writers.  (Some would
say it's not reliable for any kind of write, but ....)

If you have to do this anyway, your best bet would be to use process
redirction:

	command 2>>(tee -a sharedfile > /dev/null)

because "tee" has the kind of output-flushing behavior that you want.
(Some versions of "cat" have an option to force continuous flushing,
and I think GNU cat does so by default, so you might be able to use
that instead of tee.)

Even better would be if you could do something like:

	command 2>>(rsh nfshost "tee -a sharedfile > /dev/null")

That is, run the "tee" commands directly on the host where the file is
local, so that NFS is not involved in the write.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author