Dns-sd

Hi,
I’ve been having an issue with my computers dropping out of Apple Back to My Mac. I’d like to make a script that I can run in GeekTool to periodically list the registered computers. I can use the osascript command in BASH to make it work with GeekTool. My issue is coding for Applescript is still way beyond my comprehension.
I posted to the Apple Support Community when I thought I had a permanent fix to the BTMM drop out.

What I am attempting to do is basically:
dns-sd -B _afpovertcp._tcp|grep members| awk ‘{print $7}’

This will not work because the dns-sd runs until stopped with control -c

I found a script here that is close to what I am looking to do.

If I can get the output of dns-sd -B _afpovertcp._tcp to /tmp/BTMMStat.txt I can script the rest to bash.

I started playing with:

set expectCode to "
spawn -noecho dns-sd -B _afpovertcp._tcp
expect -timeout 10 eof {}
"
do shell script "echo" & quoted form of expectCode & "|/usr/bin/expect -f -"

But I’m not sure what I need to change to have it save to a text file.