tail copy of a file to remote location

Hello,

I have a solaris box and a windows server. The windows server runs cygwin for ssh service. I have an audit log in solaris box. When ever new records are added to the log file, this delta has to be trasported to a remote file in windows. I can do a ssh once in a while, but want the transfer to be real time. tail -f gets me this kind of output. But I don't know how to scp or sftp this output to a remote file. I am looking for a script that can do this.
I have set up a password less authentication between these two servers using public keys.

Please help me out.

Thank You

Just use rsync:

Using Rsync and SSH

(Untested)

tail -f file | ssh wherever.com "cat >> file"

I didn't know this was going to a mod first, I answered the question twice, so pick one and delete it.

Yay! I got my first 5 point infraction!

Thanks. I will try this.

It worked thanks. But when the file is rotated (The file gets deleted/renamed when it exceeds a certain size and another file with the same name gets created), the functionality is broken. It is no longer watching the new file. Is there any way of watching the new file, with out running the script again? Thanks.

With GNU tail, use

tail --follow=name file

With BSD tail,

tail -F file

.

Thanks. Problem solved at the source. tail -F works even when the file is rotated. However same problem at the destination. If I delete the file, the data no longer gets written. I wasn't even able truncate the file (although I have write permission, I was not able to write to it, when the script is running). Suggestions please. Thanks