简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM