Ending a 'do shell script' command

Hi,

I’m looking for some advice. I’m trying to use the following command to discover what ssh services I have available locally.

do shell script "dns-sd -B _ssh._tcp"
set availablessh to the result

However, the shell command to discover Bonjour ssh services needs Ctrl+C to stop, therefore I never get a result returned.
Is there any way I can send a Ctrl+C to the shell script, or anyway I can force the command to time out.
Or, possibly a better solution, is there another way to discover available bonjour services in Applescript?

Thanks.

maybe you can try to implement the following:

keystroke "c" using {control down}

the only thing that is missing is a if or try part to check how long the script is running to trigger the keystroke

greetings
goeste

Try this:

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

Works fantastically, thank you.