AppleScript Freezing while trying Shell Command

I’m trying to execute this script on my computer:

display dialog "Start"
with timeout of 2 seconds
	do shell script "service ssh start" password "password" with administrator privileges
end timeout
display dialog "End"

It’s supposed to turn on SSH access (Remote Login) on my computer when it’s run. Here’s the catch–it turns on Remote Login, but when I run the script, AppleScript hangs and I have to force quit and open it again (it never gets to the last line). I tried adding a timeout but it didn’t work. Is there some sort of AppleScript command to force the shell to stop executing once it’s complete? I’m new to this. Or, is there just a command I can use to enable Remote Login through AppleScript? I need to be able to turn on Remote Login via an AppleScript script, I really don’t care how.

Thanks!

-b

And AppleScript version 1.10.7

First of all, the “with timeout” statement allows you to alter AppleScript’s default 60-second time limit for Apple events that are sent to applications. Normally, if an application fails to respond to an Apple event within 60 seconds, AppleScript raises an “Apple event timed out” error and stops running the script. You can make this time limit shorter or longer by using with timeout. As such, since you are not sending any commands to an application in your script, the “with timeout” stuff won’t do anything for you.

I suspect that the hang is because applescript is waiting for some response from the do shell script command that it’s not receiving. I’m not familiar with your command so I can’t say why, but there is a way to get around this. I talked about this kind of solution in another topic which you can read about using the following link. Look for the second post in there.

http://bbs.macscripter.net/viewtopic.php?id=24073

Hi

Does this work for you?

do shell script "sudo service ssh start" password "password" with administrator privileges

I didn’t have any problems with this command!

Checkout your other post regarding this for an applescript way of switching on remote login.
http://bbs.macscripter.net/viewtopic.php?id=25384

Technical Note TN2065: do shell script in AppleScript

Oops!

I didn’t realise that.

Thanks for that Bruce.