user3662438
user3662438

Reputation: 121

cant execute simple bash script on raspberry pi (raspbian)

Ok, so basically i have created the script by going to bin in the terminal and typing in

sudo nano mytesterscript.sh

From there i wrote the script and saved it. To make it executable, i then used the command

    chmod +x mytesterscript.sh

then when i wanted to execute it by using

./mytesterscript.sh

I get the error:

bin/bash: bad interperter:no such file or directory

I can execute the script by typing

bash mytesterscript.sh

but i want to be able to do it like

./mytesterscript.sh

Any ideas guys?

#!bin/bash
#declare $STRING Variable
STRING= "Hello world"
#print variable on screen
echo $STRING

Upvotes: 0

Views: 2418

Answers (2)

Time Traveller
Time Traveller

Reputation: 1

have happened to me right now :D But solution is not in 1st line but in space

# replace:
STRING= "Hello world"

# by:

STRING="Hello world"

Took me approximately hour of struggling :D

Upvotes: -1

merlin2011
merlin2011

Reputation: 75629

Make sure the top of your script says:

#!/bin/bash

Observe the / in front of bin.

If that does not work, try which bash and use that output.

Upvotes: 4

Related Questions