Results 1 to 5 of 5

Thread: bash script error "let: not found"

  1. #1
    Join Date
    Jun 2006
    Location
    California
    Beans
    280
    Distro
    Xubuntu 12.04 Precise Pangolin

    bash script error "let: not found"

    I have a bash script that started to fail with "let: not found" and I'm stumped as to why.

    To troubleshoot I created a very simple script (test.sh) which also fails.

    #!/bin/bash
    let a = 1

    sh ./test.sh
    ./test.sh: 2: let: not found

    Permissions are wide open
    ls -l test.sh
    -rwxrwxrwx 1 graham graham 32 2012-02-20 11:27 test.sh

    I'm running the sh from bash
    ps
    PID TTY TIME CMD
    3800 pts/1 00:00:00 bash
    4658 pts/1 00:00:00 ps

    Let works from the bash prompt
    #let
    bash: let: expression expected

    My paths look OK (I think)

    echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/NX/bin

    thanks in advance

  2. #2
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    1,614
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: bash script error "let: not found"

    I believe that sh now links to dash and not bash. See the link in /bin to know for sure for your system.

    for your execution line try changing this:
    Code:
    sh ./test.sh
    to this
    Code:
    ./test.sh
    as I suspect your sh prefix might be overiding setting inside your script (I don't know for sure).

    Hope this helps.

  3. #3
    Join Date
    May 2010
    Location
    Tewkesbury uk
    Beans
    7,916
    Distro
    Ubuntu Development Release

    Re: bash script error "let: not found"

    Hi

    Code:
    #!/bin/bash 
    let a=1
    Try removing the spaces between a = 1.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

  4. #4
    Join Date
    Jun 2006
    Location
    California
    Beans
    280
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: bash script error "let: not found"

    Quote Originally Posted by Doug S View Post
    I believe that sh now links to dash and not bash. See the link in /bin to know for sure for your system.

    for your execution line try changing this:
    Code:
    sh ./test.sh
    to this
    Code:
    ./test.sh
    as I suspect your sh prefix might be overiding setting inside your script (I don't know for sure).

    Hope this helps.
    It did indeed, many thanks.

  5. #5
    Join Date
    Jun 2006
    Location
    California
    Beans
    280
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: bash script error "let: not found"

    Quote Originally Posted by matt_symes View Post
    Hi

    Code:
    #!/bin/bash 
    let a=1
    Try removing the spaces between a = 1.

    Kind regards
    Thanks, you're right I shouldn't have the spaces, but sh now using dash rather than bash was my issue.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •