How to show error line number while using sh

Discussion in 'Programming/Scripts' started by andipurwito, Oct 31, 2007.

  1. andipurwito

    andipurwito New Member

    Hi all...
    I have a file:
    It contains some command below:

    iptables -A INPUT -p TCP -s 0/0 -d $mynet -j Accept

    then i run it using this command:

    How to show line number in that file when an error happen?
    What is the option?

  2. falko

    falko Super Moderator ISPConfig Developer

    Not sure how to do this, but you could do something different: if you suspect a specific command to throw errors, just put the following in the next line in the script:

    if [ $? != 0 ]; then
        echo "ERROR"
    If the script displays "ERROR", then you know that the previous command threw an error; otherwise it must have been a different command, and you can move the above lines to another location in the script to continue testing.

Share This Page