Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2007
    Posts
    26

    Unanswered: Calling function

    Hi Every one

    I need Hlep i am not good at shell scripting
    i want to merge two scripts say offline as function offline()
    i need to call that functions in following way is is possilbe le me know
    -------------------------

    echo " OFF/ON"
    read option

    if [ $option -eq 'OFF' ];
    then
    offline();
    else
    online()
    fi;

    offline()
    {
    who am i > temp1.txt
    }

    online()
    {
    ls -lrt > temp2.txt
    }

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Talking No ()

    You do not need the parenthesis when cakking the function:

    Code:
    offline() {
      who am i > temp1.txt
    }
    online() {
      ls -lrt > temp2.txt
    }
    
    echo " OFF/ON"
    read option
    
    if [ "$option" -eq 'OFF' ];
    then
      offline
    else
      online
    fi
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

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