Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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)

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
    
Excellent suggestion - thank you very much! –  evilblender Aug 18 '11 at 15:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.