Apple script help

Absentee

[H]F Junkie
Joined
Aug 27, 2004
Messages
9,410
forget all this:
I suck at Applescript...gotta learn it, but I don't have time now.

I need a script. that when run, opens a window. IN this window it should have 3 buttons (or something along these lines) I need these 3 buttons to say: "Start Music Server", "Stop Music Server", and "Restart Music Server".
I need, when clicked/selected/whatever:
the 1st button to do the equivalent of running the command "/usr/local/sbin/mt-daapd -y" in Terminal
the 2nd button to do the equivalent of running the command "killall mt-daapd" in terminal...
and the 3rd button to run "killall mt-daapd; /usr/local/sbin/mt-daapd -y"

can someone help me?! this can also be done using automator and applescript...but IDK how to do either.



:EDIT:
ok...new problem...figured out the script i need to run...i just need one more thing...

Code:
if button returned of the result is "Rerun" then
          NEED THE CODE HERE, SEE BELOW
end if
Heres what I need to know how to do...(yes, i googled):
I need to restart the script...from the top...to "Rerun" it, until the Button "Close" is clicked instead of "Rerun"

I got one idea, i just dunno how to impliment it:
Copy the entire script, including this part I need, and make a new script file out of it. Then somehow run this saved script at the end of the first script (which is going in an automator action)

the other idea is, if possible...is to just restart the script from the top...


is this possible?
 
bump for a big change in topic...instead of a new thread

:edit:
DUH! "repeat until"

heres my full code:
Code:
set the task_titles to {"Start Server", "Stop Server", "Restart Server"}
set the code_list to {"echo start", "echo stop", "echo restart"}
set the chosen_tasks to (choose from list task_titles with prompt "Select which action to do:")
set the command_string to ""
repeat with i from 1 to the count of the chosen_tasks
	set this_task to item i of the chosen_tasks
	repeat with q from 1 to the count of the task_titles
		if this_task is (item q of the task_titles) then
			if i is 1 then
				set the command_string to (item q of the code_list)
			end if
		end if
	end repeat
end repeat
do shell script command_string
if command_string is "echo start" then
	display dialog "Music Server Started" buttons {"Restart Utility", "Close Utility"}
else if command_string is "echo stop" then
	display dialog "Music Server stop" buttons {"Restart Utility", "Close Utility"}
end if
--Repeat Starts
repeat until button returned of the result is "Close Utility"
	set the task_titles to {"Start Server", "Stop Server", "Restart Server"}
	set the code_list to {"echo start", "echo stop", "echo restart"}
	set the chosen_tasks to (choose from list task_titles with prompt "Select which action to do:")
	set the command_string to ""
	repeat with i from 1 to the count of the chosen_tasks
		set this_task to item i of the chosen_tasks
		repeat with q from 1 to the count of the task_titles
			if this_task is (item q of the task_titles) then
				if i is 1 then
					set the command_string to (item q of the code_list)
				end if
			end if
		end repeat
	end repeat
	do shell script command_string
	if command_string is "echo start" then
		display dialog "Music Server Started" buttons {"Restart Utility", "Close Utility"}
	else if command_string is "echo stop" then
		display dialog "Music Server stop" buttons {"Restart Utility", "Close Utility"}
	end if
end repeat
seems a little cumbersome to me..but should get the job done.

all the commands ("echo whatever") will be changed to the correct thing when the time comes that I can actually fully test it...which will be monday (hopefully)
 
Back
Top