[LBo] Running shell script
Chris F.A. Johnson
cfajohnson at teksavvy.com
Sat Jan 6 01:00:20 CET 2007
On Fri, 5 Jan 2007, Howard Rosen wrote:
>
>
> Chris F.A. Johnson wrote:
>
>> On Fri, 5 Jan 2007, Rafi Gabzu wrote:
>>
>> > I probably missed something , why in order to run shell script I
>> > need to use the dot and back slash :(e.g ./hello.sh ) ? why not just
>> > to
>> > run it ...?
>>
>> You can either use ./scriptname (that's a slash, not a backslash),
>> or you can put the script in a directory that is included in your
>> PATH. I recommend that you do the latter.
>
> Or you can start the executable, if your shebang is #!/bin/bash with bash
> scriptable.
The shebang will not make any difference. The script must
a) be in your path, or
b) you must give it an absolute path name, or
c) you give it as an argument to the bash command:
bash scriptname
>> The shell looks in the directories in your PATH variable (a
>> colon-separated list of directories), and the current directory is
>> not usually included (nor should it be).
>>
>> I recommend that you create your own directory (e.g., $HOME/bin)
>> and add it to your PATH in $HOME/.bashrc:
>>
>> PATH=$PATH:$HOME/bin
>
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
===================================================================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
More information about the QnA
mailing list