[solved]bash shell scripting (functions don't work )


Results 1 to 3 of 3

Thread: [solved]bash shell scripting (functions don't work )

  1. #1
    Join Date
    Sep 2005
    Posts
    681

    [SOLVED] bash shell scripting (functions don't work )

    I have a question. I can't get bash shell script functions to work in scripts. I am teaching my self bash shell scripting. I can get shell functions to work if i source the file. then the function works. If i put the function in .bashrc it works fine.
    Im i do a interactive-shell on CLI it works as well.

    What am i doing wrong in the script i have a simple test.


    #!/bin/bash
    # echo script name plus args
    function scriptname {
    echo "script name $0: $1 $2"
    }
    Last edited by serz; 06-13-2006 at 12:11 PM.
    "Software is like sex: it's better when its free."
    -LINUS TORVALDS

  2. #2
    Join Date
    Apr 2003
    Location
    Buenos Aires, Argentina
    Posts
    4,219
    I believe that you're only creating the function and you're not actually using it, write "scriptname" down there after the "}", I think that that will make it.
    djserz.com.ar
    "All the drugs in this world won't save you from yourself..."

  3. #3
    Join Date
    Sep 2005
    Posts
    681
    thanks. problem is solved now.
    "Software is like sex: it's better when its free."
    -LINUS TORVALDS

Posting Permissions

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