Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I'm trying to get a simple script "test1.sh" to work on my pi, but keep getting

-bash: test1: command not found

the script is literally:

#!/bin/bash

echo "Hello World!"

and called test1.sh, located in the /home/scripts directory.

I can navigate to it in terminal, but it will not run.

Iv'e set the permissions to 755 on the script and the "scripts" directory

I'm trying to run from the user pi.

any ideas what i'm doing wrong?

share|improve this question
    
What do you get when you run /bin/bash /home/scripts/test1.sh? –  Craig Feb 24 at 18:40
add comment

2 Answers

You do call your script with a path in front, like /home/scripts/test1.sh or ./test1.sh, do you? What does ls -la /home/scripts/test1.sh say?

share|improve this answer
    
OR the script has to be in an environment path. Like /usr/src I think? –  ppumkin Feb 24 at 17:56
    
That might be a good idea: Add $HOME/scripts to $PATH –  Wolf Feb 24 at 18:01
    
ls -la /home/scripts/test1.sh says: -rwxr-xr-x 1 root root 34 Feb 24 17:27 /home/scripts/test1.sh –  reggie Feb 24 at 18:04
    
Why is the file owned by root? Have you tried chown pi:pi /home/scripts/test1.sh and then calling it again? –  Wolf Feb 24 at 18:05
    
i did "pi:pi /home/scripts/test1.sh" and tried to run it again, and yes i run it using "/home/scripts/test1.sh", but still same error. i don't understand "$HOME/scripts to $PATH". Do i have to add this to my script? –  reggie Feb 24 at 18:10
show 2 more comments

this link helped

I was editing in windows, using notepad++ and then using winscp to move it over to the PI. I needed to save it in notepad as a unix file - oops!

share|improve this answer
    
That is really wierd. I use Notepad++ and Filezilla SFTP to transfer scritps over the whole time. I do a chmod +x and use ./filename.sh and its fine. Possibly you are using another encoding (another language on your computer?) Make sure its UTF8 like most English PC's hsould default to. –  ppumkin Feb 24 at 21:32
    
An editor you can use on the Pi, in terminal or SSH, is nano - easy to use, and can have syntax highlighting enabled - see here. –  Wilf Feb 25 at 13:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.