Results 1 to 2 of 2
  1. #1


    Member Since
    Dec 16, 2006
    Posts
    25
    Exclamation Shells script problem
    Hi Guys

    I have a shellscript that is located in my $Home directory, when executed it changes to a directory called "Progs" (/$Home/Progs).

    then after user input from myself it searches for another shellscript (there are a few) in that directory and if it doesn't find it it returns an error message.

    What I want to achieve is how do i extend my if statement to get it to search in another directory within Progs called Extra (/$Home/Progs/Extra) if the shell script isnt found in Progs and only if the shell script isnt in Extra the script returns an error message.

    My if statement looks like this:

    echo -n "Enter Command: "

    read FILE
    FILE=${FILE}".sh"
    if [ -f ${FILE} ]; then
    ./${FILE}
    else
    echo "File not found."
    fi

    I've set it up so I don't have to type ./scriptname.sh, only scriptname

    Any help would be appreciated

  2. #2

    rman's Avatar
    Member Since
    Dec 24, 2002
    Location
    Los Angeles, California
    Posts
    12,584
    Specs:
    2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi
    Cool
    if [ -f ${file} ]; then
    ./${file}
    elif [ -f ./Extra/${file} ] ; then
    ./${file}
    else
    echo "File not found."
    fi

    or

    if [ -f ${file} -o -f ./Extra/${file} ]; then
    ./${file}
    else
    echo "File not found."
    fi
    Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Shells for Apple Laptops
    By _Stormin in forum Apple Notebooks
    Replies: 4
    Last Post: 01-30-2012, 06:20 PM
  2. Experience with shells or cases?
    By _Stormin in forum Apple Notebooks
    Replies: 0
    Last Post: 12-31-2011, 07:00 PM
  3. Macbook shells
    By ~TheProxy~ in forum Apple Notebooks
    Replies: 4
    Last Post: 02-03-2010, 09:21 AM
  4. Searching for Shells
    By Village Idiot in forum Images, Graphic Design, and Digital Photography
    Replies: 0
    Last Post: 10-02-2007, 11:05 AM

Posting Permissions

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