[colug-432] Script basic

Steve VanSlyck s.vanslyck at postpro.net
Wed May 13 14:12:20 EDT 2015


Umpf.

Yes, I have seen it before, now you mention it. Seems my old windows
machines always started with PATH=.;... Or at least I seem to remember
it that way. Regardless, I always *assumed* the computer always looked
in the current directory first.

Anyway, as you saw in previous email i am now getting this [root at vslaw2
~]# ./server_setup.sh -bash: ./server_setup.sh: /bin/bash^M: bad
interpreter: No such file or directory error.

No idea what the ^M means. I don't see anything when looking at the file
in nano and confirmed it with VI/VIM just to be sure, with same result

On Wed, May 13, 2015, at 14:04, Rick Hornsby wrote:
>
>> 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
>
> _________________________________________________
> 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/bc8fbe6e/attachment.html 


More information about the colug-432 mailing list