OS X 10.6.6 Script label and goto problems.

February 19, 2011 at 13:27:27
Specs: Mac OS X 10.6.6
I am trying to make this script, that installs a java server for a game.

This is the script:

And I get this error:
line 12: ask:: command not found

I use "ask:" as a label, and then goto ask, but I can't seem to get "ask:" to be read as a label...
If anyone can help me I would be thankful.
Thanks for your time.

See More: OS X 10.6.6 Script label and goto problems.

Report •

February 19, 2011 at 17:06:54
I can't see your script as it requires a log in, but since this is in the batch section (even though you are on a mac?) switch it to ":ask"

Can I put a question here?

Report •

February 27, 2011 at 00:03:40
I am on a Mac.
Even with ":ask" I get the error.
And here is the code:

echo 'Welcome to the Mac OS X Bukkit Installer version 1.3!'

echo "How much Ram do you want to give Bukkit?"
echo "Choose frome this list:"
echo " 512=512MB;  1024=1GB;  1536=1.5GB;  2560=2.5GB;  3072=3GB;  5120=5GB"

#First label.
read amountram
if (amountram ∉ {512;1024;1536;2560;3072;5120} ) then goto error

mkdir ~/bukkit_server
cd ~/bukkit_server

curl -O <a href="http://artifacts.lukegb.com/artifac...0.0.1-SNAPSHOT/craftbukkit-0.0.1-SNAPSHOT.jar" target="_blank">http://artifacts.lukegb.com/artifac...</a> <a href="http://artifacts.lukegb.com/artifactory/libs-snapshot-local/org/bukkit/craftbukkit/0.0.1-SNAPSHOT/craftbukkit-0.0.1-SNAPSHOT.jar" target="_blank">http://artifacts.lukegb.com/artifac...</a>
mv craftbukkit-0.0.1-SNAPSHOT.jar craftbukkit.jar

echo '#!/bin/sh java -Xingc -Xmx'$amountram'M -jar craftbukkit.jar' >>serverstart.sh
chmod +x serverstart.sh
cp -l serverstart.sh "~/Desktop/Start Bukkit Server"

echo " _____   _____   __   _   _____        "
echo "|  _  \ /  _  \ |  \ | | | ____|  |    "
echo "| | | | | | | | |   \| | | |__    |    "
echo "| | | | | | | | | |\   | |  __|   |    "
echo "| |_| | | |_| | | | \  | | |___   |    "
echo "|_____/ \_____/ |_|  \_| |_____|  O    "

#Second label.
echo "Invalid amount, please enter a valid number from the folowing list:"
echo " 512=512MB;  1024=1GB;  1536=1.5GB;  2560=2.5GB;  3072=3GB;  5120=5GB"
goto ask

#The error I get is:
#line 12: ask:: command not found
#Which is the label that I use to goto. (I guess you know!)
#Thanks for your time.

Report •

February 27, 2011 at 02:30:25
There are many things wrong with this script. For a start, you don't use labels and gotos in OS X shell scripts. Use a looping construct instead:

while read c
echo $c

For a second, as you can see in this example, you need to prefix variable names with $ when you want to extract their value (but not when assigning to the variable), and so on and so on. It looks to me as if you are trying to apply MS-DOS batch file constructs to an OS X shell script. That's just not going to work.

Have a look at this introduction to shell scripting and practice with a few simple scripts before trying anything more ambitious. Alternatively, you could always use AppleScript.

Report •

Related Solutions

February 28, 2011 at 06:54:26
Now I have only one problem:
When I output to the launcher, I want no spaces around the variable.
Is there a way to do that?

Report •

Ask Question