I'm relatively new to this and probably do a lot of things in very backwards and incorrect ways, but any help that could be offered would be greatly appreciated.
I'm working Ubuntu 10.04 and I have two scripts that I use to update machines remotely, the first is a scheduled cron job that runs every hour, and it wget's the second file which actually contains the patch, runs it, and then deletes it. It also directs the output of the patch to a file called log.
The tricky part comes in the patch itself, as it uploads the output of itself (the log file) to a website(I know...). The upload command is at the end of the patch, but the upload is still failing due to the output not being written yet.
So, is it possible to have the output write to the file as it occurs rather then letting the script finish? I can provide any code needed if this is to vague or just doesn't make sense.
No, unless you decouple from the upload. You could use NFS or the like to move the file after you exit. You have two competing goals, to ensure a complete upload before exiting and to write that status in the log you have already uploaded just before you exit. I flash on the monkey trap made from a coconut! You could make two logs that are spliced together by a frame or such, and send the upload log later. Of course, then you would need an upload log upload log, and if you upload that . . . .
I don't know if this fits your environment/problem domain, but could you do a remote execution using ssh and have the logging information come back to you on the stdout? Once the ssh terminates you would have all of the log file and then could put it up on the web site.
Past rsync there is NFS, AFS mounting of disks between systems. Is there a secure rsync using ssh/scp? However, checking for errors is just moved to the tool doing the communication. Usually, both ends have crons to check that the other end is working. This removes some stress from the sender. He can write the local log even if cut off, knowing his opposite number will rat him out to the real world.