0

this is my first question.

I use Multisystem all of the time and have installed it on both Kubuntu and Ubuntu and have used it with no issues. I wiped my hard drive to try some new OSs I'm now using the exact same OS (Ubuntu 12.05) I used to load my USB stick to begin with and now I'm getting this ridiculous syntax error. I know the script is correct, I'm following the exact same steps I used to get to this point and I'm getting different results ?!?! I'm very confused by this.

I have no clue how to begin addressing this issue. I get the same syntax error on Kubuntu now too, which did have multisystem installed.

I run "sh install-depot-multisystem.sh" and get "Syntax error:redirection unexpected", this worked literally 2 days ago. The only thing that has changed is my face has grown some more facial hair and my head hurts from bangin it against the wall over this issue.

The OS is exactly the same, the script is the same; but now it won't install. I'm lost and really hoping someone can help.

Append

Just to append to this a bit

https://lists.ubuntu.com/archives/ub...er/000264.html

I needed to do a chmod 777 on the script, I'm still getting a syntax error on Kubuntu...but it did install successfully. I'll mark this as resovled!

Thanks anyway, I'll try to spruse up on my Linux skills.

1
  • 1
    chmod 777 is never a solution, and unlikely the part that fixed it, it rather opened a security hole. My guess is the script is actually a bash script, which is not the same as an sh script. The script does have a misleading extension if that's the case, but that's unfortunately very common; the vast majority of shell scripts out there on the intertubes are badly written. Also, the link is broken.
    – geirha
    Jul 2, 2012 at 22:17

2 Answers 2

3

The script was effective even with the syntax error, so it seems that this question really boils down to how to run a script.

Running as an Executable File

To run a script that is in the current directory without explicitly invoking the shell, you must preface its name with ./. It must also be executable.

chmod u+x install-depot-multisystem.sh
./install-depot-multisystem.sh

That will only work if the script starts with a hashbang line specifying what shell is supposed to run it.

If you ran chmod 777 on the script, and that helped, then the reason it helped was almost certainly that it gave you, as the owner of the script, execute permissions on the script. You also gave yourself and all other users read and write permissions, as well as execute permission to all other users. This is unnecessary, potentially a serious security problem. chmod u+x is just as good, and much safer.

Invoking the Shell

Alternatively you can run the script by explicitly invoking the shell, like you had tried initially:

sh install-depot-multisystem.sh

The script has a .sh extension, so it should be runnable with sh. But in case the script author named it badly, and it's really a bash script, you can try running with bash (as geirha suggested):

bash install-depot-multisystem.sh

Running in the Current Shell

This is included for completeness only--unless you wrote the script and know this will work properly, or the instructions that accompany the script say to run it this way, you should use one of the previous two methods instead. Many scripts will only work right if they have their own shell in which to run (which is accomplished by either of the above two methods).

With that said, you can attempt to run the script in the current shell, with the current shell's environment, with either of the following commands:

. install-depot-multisystem.sh
source install-depot-multisystem.sh

Running as root

If the script is installing a systemwide program or service, it might need to be run as root. Do not run a script (or anything) as root unless you know you need to do so.

To run it as root, put sudo in front of the command that runs it. Any of these three commands will work (though the first still requires execute permissions):

sudo ./install-depot-multisystem.sh
sudo sh install-depot-multisystem.sh
sudo bash install-depot-multisystem.sh
-1

this is not sh it's bash Not use "sh install-depot-multisystem.sh" just use: install-depot-multisystem.sh

1
  • You can't run a script in the current directory by entering its name as the full command. It must be prefixed by ./ or similar. It must also be given executable permissions, if it doesn't have them. Jul 6, 2012 at 12:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .