Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

help with automator

hello, i want to make a program to lunsh my minecraft server in automator. i have made this so far:


User uploaded file

and when i start it this come:


User uploaded file


when i press yes it starts my server and if i press no it stops


but i want to know how to make kind off a stop command to stop the server


pleace help me!!

Mac mini, Mac OS X (10.6.8), 2010 edition

Posted on Jul 28, 2012 3:44 PM

Reply
14 replies

Jul 29, 2012 5:05 AM in response to oppentrapp from norway

Hi,


Here's a solution :


Delete your two actions.

Adds the "Run AppleScript" action.

Copy/paste this script in the action.

------------------------

onrun

set r to display dialog "Start or stop the bukkit server ?" buttons {"Stop", "Start"}

if button returned of r is "Start" then

do shell script "echo 'Start' "

else

do shell script "echo 'Stop' "

end if

endrun

------------------------

Change the shell commands.

Jul 29, 2012 7:20 AM in response to oppentrapp from norway

How you stop the server wil depend on the server. In Jacques' script you will need to replace the echo commands wiht the proper commands for your server.


In your example you show a start_server.command script. Is there also a stop_server.command script? If so it would go in place of the echo stop line.


ie.


if button returned of r is "Start" then

do shell script start_server.command

else

do shell script stop_server.command

end if

Jul 30, 2012 8:36 AM in response to oppentrapp from norway

Hi,


oppentrapp from norway wrote:


i dont have a stop_server.command 😟


To stop the server, you must type 'stop' into the Terminal window.

Closing the Terminal window without stopping the server could lead to corruption of the save files.


Here is the complete script.

-----------------------------------

onrun

set myCommand to "cd '/Users/jack/minecraft' && java -Xmx3G -Xms3G -jar craftbukkit.jar"


set r to display dialog "Start or stop the bukkit server ?" buttons {"Stop", "Start"}

set serverRunning to do shell script "/bin/ps -ax | /usr/bin/grep ' craftbukkit.jar' | /usr/bin/grep -v 'grep' || true"

ifbutton returnedofris "Start" andserverRunningis "" then -- the server is not running.

tell application "Terminal"

if running or not (exists window 1) then

do script myCommand

else

do script myCommand in tab 1 of window 1

end if

end tell

else if button returned of r is "Stop" and serverRunning is not "" then -- server run

tell application "Terminal"

set tTab to ""

repeat with this_wind in (get windows)

try

set tTab to (first tab of this_wind whose its contents contains "-jar craftbukkit.jar")

end try

end repeat

if tTab is not "" then -- found tab

do script "stop" in tTab

repeat while "java" is in (get processes of tTab) -- loop until the server is stopped.

delay 2

end repeat

if (countwindows) is 1 and (counttabsofwindow 1) is 1 thenquit -- no others processes, quit the Terminal

end if

end tell

end if

endrun

-----------------------------------

Replace this text in the second line : /Users/jack/minecraft by the path of your "minecraft" folder

Sep 22, 2013 10:06 AM in response to oppentrapp from norway

Okay I am wondering how to even get started in this because I want to use automator to run my server too, but I don't know where do I put all of the script stuff? Do I have to change the start.command to that long script that Jacques put or what exactly do I have to use. Like I tried that script in automator and it didnt work and I tried the same thing as oppentrapp and it didn't work. Does anyone know if I have to put _ instead of a space because my folder w/ the server has spaces in it. Sorry if I am not making sense I just want to know how do I make like a script and what like exactly do I have to put? Thanks so much!

Sep 22, 2013 10:17 AM in response to urmastertech

Well to get it to start by itself you can just make the start command a "log-on object" in the profiles tab in system settings.


But when it comes to the mac asking you if you want it to start the server you will need a little apple script that I you can make in just 5 mins (or less) just use the "display dialog" script-thing! ;)


Hope it helps :)

Sep 22, 2013 10:55 AM in response to oppentrapp from norway

I don't have profiles is it because I am using snow leopard? I will eventually upgrade to lion, but snow leopard is working fine for me. I only can upgrade to lion which *****, but I don't think I will need mountain lion or the new one coming out this year or next year I forgot when, but I think I will just make it all out of applescript because it seems pretty easy that way. I already sort of made a applescript one I just gotta make it better because I didn't know when you record it records like everything, but anyway thanks for the help I will maybe make a applescript today when I get time, but thanks for all the help! πŸ˜€ πŸ˜€ πŸ˜€ πŸ˜€ πŸ˜€ lol lots of smily faces! πŸ˜€

help with automator

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.