13

Possible Duplicate:
How do I run .sh files in Terminal?

I'm trying to install Craftbukkit on my Ubuntu 12.04 server. However, I'm having issues with step seven, which instructs me to run ./craftbukkit.sh.

If I run it as a normal user, then I get a permissions error. If I run it using sudo, then I get sudo: ./craftbukkit.sh: command not found.

What am I doing wrong?

2 Answers2

23

You need to chmod the file 1st before run.

chmod +x file.sh

Now your can run your .sh file as follows

./file.sh

Another way to run .sh file in Linux

sh file.sh

OR

bash file.sh
penreturns
  • 5,950
4

According to the wiki page of bukkit.

[...] type sh craftbukkit.sh to execute the script you wrote before. Your server will start and keep running until you stop it (or until it crashes).

pl1nk
  • 6,399
  • Thanks, this helped me find the issue (Java wasn't installed. Duh....) – SomeKittens Jun 19 '12 at 18:20
  • 1
    Passing an explicit shell instead of letting the system infer the right script form the shebang might lead to errors. It*s just a matter of luck that it worked here. – user unknown Jun 19 '12 at 19:10
  • @userunknown: Well these are the contents of craftbukkit.sh: #!/bin/sh screen java -Xms1024M -Xmx1024M -jar craftbukkit.jar http://wiki.bukkit.org/Setting_up_a_remote_Linux_server – pl1nk Jun 19 '12 at 19:44
  • 1
    I told you, that it might be a matter of luck, if it works. Why don't you use sudo ./craftbukkit.sh? – user unknown Jun 19 '12 at 20:55
  • 1
    @userunknown You have to chmod +x ./craftbukkit.sh first, in this situation.. – Eliah Kagan Jun 19 '12 at 21:05
  • @userunknown: Actually it must be run this way (as per the wiki page), check my improved answer. – pl1nk Jun 19 '12 at 21:06
  • @pl1nk: Do you think the people behind craftbukkit are the ultimate authority in shell scripting? One thing is to heal a lousy installation routine with sloppy advices by half educated programmers - get the thing running - the other thing is to learn something which isn't too localized. chmod is fine thing to do, if it isn't executable per se - else you have to remember always to put sh in front, and not bash and you can't use auto completition to run it and you won't find it with find -executable, not with whereis and which - a whole bunch of drawbacks. – user unknown Jun 20 '12 at 01:55
  • @userunknown: Did you even checked this wiki page? I'm wondering to which lousy installation routine are you refering to ? I don't agree with your comment and especially with your characterization to the half educated programmers ? Seriously ? – pl1nk Jun 20 '12 at 06:49
  • @EliahKagan: It was already executable., Author: SomeKittens, Jun 19 at 18:21 in a comment to penreturns answer. – user unknown Jun 24 '12 at 20:50