[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: My bash script is missing something - what?



Hi,

Richard Owlett wrote:
> > >      bash: test.sh: command not found

Robert Parker wrote:
> > you need to do:./test.sh

Richard Owlett wrote:
> That just fails differently by responding:
> : No such file or directory
> At the moment I using
>   http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_01.html

It states
  "If you did not put the scripts directory in your PATH, and . (the
   current directory) is not in the PATH either, you can activate the
   script like this:

     ./script_name.sh 
  "

So on the first hand it was about the environment variable named "PATH".
Do

  echo $PATH

to get a list of directories where programs will be found automatically.
The directory paths are separated by ':' characters. E.g.

  /usr/local/bin:/usr/bin:/usr/local/games:/usr/games:/home/thomas/bin

----------------------------------------------------------------------

But what does now prevent proper execution ?

I tested the script as shown by you. It works and says

  8.X
  /dev/sdaY on / type ext4 (rw,noatime,discard,errors=remount-ro,data=ordered)

(with X and Y being private numbers. :))

So this must be some flaw hidden from the human eye and copy+paste.

Be so kind and let program "od" show the bytes of your script.

  od -c test.sh

For me it says

  0000000   #   !   /   b   i   n   /   b   a   s   h  \n   c   a   t    
  0000020   /   e   t   c   /   d   e   b   i   a   n   _   v   e   r   s
  0000040   i   o   n  \n   m   o   u   n   t       |       g   r   e   p
  0000060       '   o   n       /       '  \n  \n
  0000072

This should show us any CarriageReturn characters, which Greg suspects
to be to blame.


Lars Norden wrote:
>         #!/bin/bash -x

Good proposal, too.
(I would have proposed command

   set -x

as second line of the script.)


Have a nice day :)

Thomas


Reply to: