Converting batch language to applescript to run a program

Discussion in 'Mac Programming' started by Hobbit Shado, Aug 27, 2010.

  1. Hobbit Shado macrumors newbie

    Joined:
    Aug 27, 2010
    #1
    Can anyone help me convert this?

    @echo off
    title Hobbitscape
    javac -source 1.5 -target 1.5 -classpath . -d bin *.java -g
    title Hobbitscape is now running.

    cd bin

    java -Xmx800M server
    color f0
    pause

    I need this converted so I can run my Server
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    echo -n -e "\033]0;Hobbitscape\007"
    javac -source 1.5 -target 1.5 -classpath . -d bin *.java -g
    echo -n -e "\033]0;Hobbitscape is now running\007"

    cd bin
    java -Xmx800M server > /dev/null 2> /dev/null &

    Setting color I'm not sure about.

    -Lee
     
  3. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #3
    Further to lee1210's answer, and to clarify, this is a shellscript -- which is stored in a file (e.g. "go.sh") and run from Terminal.

    Code:
    #!/bin/bash
    
    echo -n -e "\033]0;Hobbitscape\007"
    javac -source 1.5 -target 1.5 -classpath . -d bin *.java -g
    echo -n -e "\033]0;Hobbitscape is now running\007"
    
    cd bin
    java -Xmx800M server > /dev/null 2>&1 &
    
    If you prefer, you can use Automator to build a standalone 'application' which can be double-clicked as normal (and therefore does not require you to first open Terminal and type the name of the script...).

    Automator is also a good way to find out what is possible... For example the "Speak Text" action is fun (type "man say" in Terminal for more information about the command-line tool).
     
  4. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #4
    I should have been more specific, I just always tend toward a shell script rather than an AppleScript. For this particular case, the java command is really the crux. I rarely recompile every time I run a program.

    Also, this script could be run via clicks in finder. There is nothing interactive, the script finishes after starting the java program, etc.

    -Lee
     
  5. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #5
    Does that work for you? If I double-click on some "foo.sh" file it opens XCode :)
     
  6. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    Try .command for your extension.

    -Lee
     

Share This Page