[colug-432] Script basic

Rick Hornsby richardjhornsby at gmail.com
Wed May 13 14:04:28 EDT 2015


> On May 13, 2015, at 12:53, Steve VanSlyck <s.vanslyck at postpro.net> wrote:
> 
> I have a script. The first line is
>  
> #!/bin/bash
>  
> When I run the script, I get a command not found error:
>  
> [root at vslaw2 ~]# server_setup.sh
> -bash: server_setup.sh: command not found

UNIX looks for binaries and scripts in your PATH  (echo $PATH).  Since . isn't in your path, you need to provide the path to the command you're trying to run.  You've almost certainly seen this syntax before - the most common way is to be in the directory where the script lives, and use ./ (dot slash) like so:

./server_setup.sh

. means the same thing it does in DOS/Windows - refers to the current working directory.

Note - I've never seen anyone put . in their UNIX path and I wouldn't recommend it.  IIRC the reason behind this -- it ensures that when you run (for example) visudo, you're getting the real /usr/sbin/visudo and not a rogue binary in whatever the current directory happens to be.  /usr/sbin tends to be more secured from tampering than some other random directory on the filesystem where you might be while trying to execute visudo (again, visudo is just an example) from.



> I see bash at /bin . . .
> [root at vslaw2 ~]# ls -lsap /bin/bash
> 884 -rwxr-xr-x 1 root root 904872 Oct 16  2014 /bin/bash
>  
> . . . and my script appears to have the correct permissions
> [root at vslaw2 ~]# ls -lsap server_setup.sh
> 8 -rwxr-xr-x 1 root root 4232 May 13 13:40 server_setup.sh
>  
> Anyone have an idea what I'm doing wrong?
>  
>  
> (And by the way I seriously appreciate all the help!)
>  
>  
> Steve
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20150513/58d9c9ce/attachment-0001.html 


More information about the colug-432 mailing list