How can I...Restart on Error?

Thank you Mikey-San. Would you please elaborate on the proper syntax for sudo? I have never understood the interaction between admin privileges and sudo as to how it affects security.

Mine certainly was a bad idea, and the man page even says not to do this.

cordially,
Andy

Browser: Safari 412
Operating System: Mac OS X (10.4)

can i just say i agree 100% with this. seriously.

i found a good hint this morning for shutting down the FMS:

http://forums.macosxhints.com/archive/index.php/t-20770.html

it seems that the FMS daemon is called fmserverd, and it has it’s own flags and commands. apparently just shutting down the FMS can corrupt your databases! be cautious, make sure you back up and test everything, but it looks like this might be a good solution:

try
	--check for FMP freeze here
on error
	do shell script "/Applications/FileMaker Server 5.5/FileMaker Server Config.app/Contents Resources/fmserverd CLOSE /path/To/Database"
	do shell script "/Applications/FileMaker Server 5.5/FileMaker Server Config.app/Contents Resources/fmserverd STOP"
	delay 1
	do shell script "/Applications/FileMaker Server 5.5/FileMaker Server Config.app/Contents Resources/fmserverd START"
	do shell script "/Applications/FileMaker Server 5.5/FileMaker Server Config.app/Contents Resources/fmserverd OPEN /path/To/Database"
end try

it is not clear to me how to use the CLOSE and OPEN commands on more than one DB (without using multiple “do shell’s”), but i don’t have FMS…

it is also not clear whether the daemon itself stops responding. if that is the case, it may come down to a “killall fmserverd”, but i would err on the side of caution since the DB’s seem to be easily corrupted.

cheers.

EDITED for clarity.

sudo gives an account admin privilege for 5 minutes during which someone else could do something nasty - it is intended for use from the terminal where a sequence of instructions requiring privilege will be executed and you don’t want to have to enter your password for every one. “With admin privilege”, intended for AppleScripts, lasts only as long as it takes to do the operation requiring it.

Normally, after using sudo in the Terminal, one follows it with sudo -k which kills the permission. That instruction does not require a password, it always works.

hi andy,

this is basically sudo in AppleScript:

do shell script "/path/to/executable <commands>" with administrator privileges

as you correctly noted, you could also add the password to the command, so that you don’t get the prompt. if you do this i would caution you to make your AppleScript a “run only” application, so that the Admin password cannot be easily read (security hazard).

cheers.

Basically, but please understand that there is a difference in what happens.

“With administrator privileges” does not invoke sudo to obtain privilege for executables. Instead, Authorization Services is used to gain administrator-level authorization for a given tool.

Now I get it! Thank you so much for your replies.

Andy

Browser: Safari 412
Operating System: Mac OS X (10.4)