Newbie Shell Script question. - Ubuntu

This is a discussion on Newbie Shell Script question. - Ubuntu ; Sorry but can anyone tell me why my (first ever) shell script won't execute? -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh root@richard-laptop:/home/richard/Desktop# Record1 bash: Record1: command not found root@richard-laptop:/home/richard/Desktop# Record1.sh bash: Record1.sh: command not found root@richard-laptop:/home/richard/Desktop# As far as ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Newbie Shell Script question.

  1. Newbie Shell Script question.

    Sorry but can anyone tell me why my (first ever) shell script won't
    execute?

    -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    root@richard-laptop:/home/richard/Desktop# Record1
    bash: Record1: command not found
    root@richard-laptop:/home/richard/Desktop# Record1.sh
    bash: Record1.sh: command not found
    root@richard-laptop:/home/richard/Desktop#

    As far as I can see it is executable. I am under the impression that I
    can execute by just entering its name if in the current working directory.

    Richard.

  2. Re: Newbie Shell Script question.

    Richard wrote:
    > Sorry but can anyone tell me why my (first ever) shell script won't
    > execute?
    >
    > -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    > root@richard-laptop:/home/richard/Desktop# Record1
    > bash: Record1: command not found
    > root@richard-laptop:/home/richard/Desktop# Record1.sh
    > bash: Record1.sh: command not found
    > root@richard-laptop:/home/richard/Desktop#
    >
    > As far as I can see it is executable. I am under the impression that I
    > can execute by just entering its name if in the current working directory.


    Maybe the PATH variable is not set appropriately.
    Try "./Record1.sh".
    BTW Adding "." to the PATH is considered a security issue.

    Josef
    --
    These are my personal views and not those of Fujitsu Siemens Computers!
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize (T. Pratchett)
    Company Details: http://www.fujitsu-siemens.com/imprint.html


  3. Re: Newbie Shell Script question.

    On Mon, 08 Oct 2007 13:57:21 +0200, Josef Moellers wrote:

    > Richard wrote:
    >> Sorry but can anyone tell me why my (first ever) shell script won't
    >> execute?
    >>
    >> -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    >> root@richard-laptop:/home/richard/Desktop# Record1 bash: Record1:
    >> command not found
    >> root@richard-laptop:/home/richard/Desktop# Record1.sh bash: Record1.sh:
    >> command not found
    >> root@richard-laptop:/home/richard/Desktop#
    >>
    >> As far as I can see it is executable. I am under the impression that I
    >> can execute by just entering its name if in the current working
    >> directory.

    >
    > Maybe the PATH variable is not set appropriately. Try "./Record1.sh".
    > BTW Adding "." to the PATH is considered a security issue.
    >
    > Josef



    Cured itself!

  4. Re: Newbie Shell Script question.

    Richard writes:

    > Sorry but can anyone tell me why my (first ever) shell script won't
    > execute?
    >
    > -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    > root@richard-laptop:/home/richard/Desktop# Record1
    > bash: Record1: command not found
    > root@richard-laptop:/home/richard/Desktop# Record1.sh
    > bash: Record1.sh: command not found
    > root@richard-laptop:/home/richard/Desktop#
    >
    > As far as I can see it is executable. I am under the impression that I
    > can execute by just entering its name if in the current working directory.
    >
    > Richard.


    ../Record1.sh

    or

    /path/to/it/Record1.sh

    or sometimes even

    sh ./myscript.sh



    --
    O que importa nao e o fato, mas a versao.
    -- Jose Maria Alkmin

  5. Re: Newbie Shell Script question.

    On Mon, 08 Oct 2007 06:51:08 -0500, Richard wrote:

    > Sorry but can anyone tell me why my (first ever) shell script won't
    > execute?
    >
    > -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    > root@richard-laptop:/home/richard/Desktop# Record1
    > bash: Record1: command not found
    > root@richard-laptop:/home/richard/Desktop# Record1.sh
    > bash: Record1.sh: command not found
    > root@richard-laptop:/home/richard/Desktop#
    >
    > As far as I can see it is executable. I am under the impression that I
    > can execute by just entering its name if in the current working directory.
    >
    > Richard.


    I would imagine because your current directory is not in your path. Try
    ../Record1.sh


  6. Re: Newbie Shell Script question.

    On 2007-10-08, Richard wrote:
    > On Mon, 08 Oct 2007 13:57:21 +0200, Josef Moellers wrote:
    >
    >> Richard wrote:
    >>> Sorry but can anyone tell me why my (first ever) shell script won't
    >>> execute?
    >>>
    >>> -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    >>> root@richard-laptop:/home/richard/Desktop# Record1 bash: Record1:
    >>> command not found
    >>> root@richard-laptop:/home/richard/Desktop# Record1.sh bash: Record1.sh:
    >>> command not found
    >>> root@richard-laptop:/home/richard/Desktop#
    >>>
    >>> As far as I can see it is executable. I am under the impression that I
    >>> can execute by just entering its name if in the current working
    >>> directory.

    >>
    >> Maybe the PATH variable is not set appropriately. Try "./Record1.sh".
    >> BTW Adding "." to the PATH is considered a security issue.
    >>
    >> Josef

    >
    >
    > Cured itself!


    FWIW, whenever I am writing a script that I want to run more than once
    I stick it in my ~/bin (~ stand for my home directory) and add
    ~/bin to my path in my .bashrc This way, as long as there is
    no other script with the same name found at a location earlier
    in my path, I can run it no matter what directory I'm in.


    --
    PSK - RLU 452647 http://improve-usenet.org
    Killing GG on Ubuntu, openSUSE, Vista and XP with slrn and Xnews
    ~Nick: People are pigs.
    ~Grissom: Don't insult the pigs, Nick. They're actually very clean.

  7. Re: Newbie Shell Script question.

    Richard wrote:
    > On Mon, 08 Oct 2007 13:57:21 +0200, Josef Moellers wrote:
    >
    >> Richard wrote:
    >>> Sorry but can anyone tell me why my (first ever) shell script won't
    >>> execute?
    >>>
    >>> -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    >>> root@richard-laptop:/home/richard/Desktop# Record1 bash: Record1:
    >>> command not found
    >>> root@richard-laptop:/home/richard/Desktop# Record1.sh bash: Record1.sh:
    >>> command not found
    >>> root@richard-laptop:/home/richard/Desktop#
    >>>
    >>> As far as I can see it is executable. I am under the impression that I
    >>> can execute by just entering its name if in the current working
    >>> directory.

    >> Maybe the PATH variable is not set appropriately. Try "./Record1.sh".
    >> BTW Adding "." to the PATH is considered a security issue.
    >>
    >> Josef

    >
    >
    > Cured itself!


    Don't get me wrong, I'm not fishing for compliments (I know I'm the best
    here on this sofa anyway ;-), but it would be helpful to others to
    explain how the problem "cured itself". Just a few words like "forgot to
    put a shebang line into the script" or the like.
    Did my remarks help or what did you do to get it going?

    Josef
    --
    Mails please to josef dot moellers
    and I'm on gmx dot de.

  8. Re: Newbie Shell Script question.

    Richard has written on 10/8/2007 7:51 AM:
    > Sorry but can anyone tell me why my (first ever) shell script won't
    > execute?
    >
    > -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    > root@richard-laptop:/home/richard/Desktop# Record1
    > bash: Record1: command not found
    > root@richard-laptop:/home/richard/Desktop# Record1.sh
    > bash: Record1.sh: command not found
    > root@richard-laptop:/home/richard/Desktop#
    >
    > As far as I can see it is executable. I am under the impression that I
    > can execute by just entering its name if in the current working directory.


    You are treating the filename as if, as in DOS/Windows, it had two parts
    - a name and an extension.

    In *nix, there are only names. Thus if you wish to execute Record1.sh,
    you must type Record1.sh at the command prompt.

    And if the directory where Record1.sh is not in PATH, you will have to
    type the absolute pathname of the file. Exception: if the current
    directory is where Report1.sh is stored and it is not in the PATH, just
    type ./Report1.sh

  9. Re: Newbie Shell Script question.

    On 2007-10-08, Richard wrote:
    > Sorry but can anyone tell me why my (first ever) shell script won't
    > execute?
    >
    > -rwxr-xr-x 1 richard richard 135 2007-10-08 11:46 Record1.sh
    > root@richard-laptop:/home/richard/Desktop# Record1
    > bash: Record1: command not found
    > root@richard-laptop:/home/richard/Desktop# Record1.sh
    > bash: Record1.sh: command not found
    > root@richard-laptop:/home/richard/Desktop#
    >
    > As far as I can see it is executable. I am under the impression that I
    > can execute by just entering its name if in the current working directory.
    >
    > Richard.


    True for DOS, not for *nix. If your current directory is not in PATH,
    you must say "./Record1"

    --
    MarkA
    (This space accidentally filled in)

+ Reply to Thread