0

I have a server that my machine is connected to via AFP. On this server there is a file called 'TransferLog.txt'. While the server is doing it's work it adds to this file. When it finally writes 'successful' I want to be notified by a pop up window in the finder.

Normally I would attack this using 'tail -f' and 'grep'. However, I have found that because this file is sitting on a server rather than a local file on my hard drive 'tail -f' doesn't seem to work properly... it behaves like 'tail', listing it's current last lines, but then just sits there and doesn't update info... it also doesn't exit.

Does anyone have any suggestions on how to monitor this remote file more effectively? Is there a way I could repeatedly read the tail output looking for 'successful' using applescript? (I'm pretty bad with applescript)

1

I don't think a network filesystem is going to give you enough state information to do this quite as simply as you asked. One solution would be this:

On the server side, run a script that looks for your 'successful' string as you described. When it finds the string, have it write a new file into the shared directory.

On the remote side, run a script that checks for this new file, e.g.:

test -f newfilename && echo 'Success!' && rm newfilename

Once you've been notified, you can delete this new file and loop around for the next time. The file creation and deletes should be reliably communicated across the network.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .