Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Server is running FreeBSD 9.2.

Using vim, I wrote the following script called hello:

#!/bin/sh
echo "hello world"

Then I set it as executable:

>chmod 755 hello

Then I tried to run it from the command line (while in the same folder where the script was saved):

>hello

I got this error message:

hello: Command not found.

Is there something different I have to do to make an executable script in BSD?

share|improve this question
    
This is common to nearly every Unix-like system, and is not specific to (Free)BSD. –  jw013 May 8 at 17:47

1 Answer 1

up vote 4 down vote accepted

You must type:

./hello

If you type hello, the shell will try to find in $PATH any executable program named hello. In your case, you have not added your current folder to $PATH, so the shell can not find your program.

Dot . in ./hello represent your current working directory, so the shell can expand it to /full/path/to/hello.

share|improve this answer
    
Yes, my current folder is not in $PATH. This works, thank you. –  sigil May 8 at 17:48

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.