开发者

Error in small sh script

When I run program and I click on "Yes" throws an error:

/home/zygis/tools/script: 26: Syntax error: ")" unexpected (expecting ";;")

Code:

DIALOG=${DIALOG=dialog}

$DIALOG --title " My first dialog" --clear \
        --yesno "You really want to run this program?" 10 30

case $? in
  0)
    if [ "$1" = "start" ];
    then
            echo "Enter OS: ";
            read OS
            echo OS
            python /home/zygis/tools/dj.py $OS
    else
        if [ "$1" = "uprint" ];
        then
            echo "usage: {start}";
            echo "example: (./boot start)";
        else
            echo "Invalid cho开发者_运维知识库ice";
            echo "To usage use uprint";
        fi
    fi
  1)
    echo "No chosen.";
  255)
    echo "ESC pressed.";
esac


Each case of your case/esac must be terminated by ;;. See the man page...

case $? in
  0)
    if [ "$1" = "start" ];
    then
            echo "Enter OS: ";
            read OS
            echo OS
            python /home/zygis/tools/dj.py $OS
    else
        if [ "$1" = "uprint" ];
        then
            echo "usage: {start}";
            echo "example: (./boot start)";
        else
            echo "Invalid choice";
            echo "To usage use uprint";
        fi
    fi
    # Terminate.....
    ;;
  1)
    echo "No chosen.";
    # Terminate.....
    ;;
  255)
    echo "ESC pressed.";
    # Terminate.....
    ;;
esac


You have to use ";;" to end your cases.

case $? in
    0)
        echo "case 0";;
    1)
        echo "case 1";;
esac


Use two semicolon ;; to end each case i.e:

case ...
1) some_command ;;
2) other command ;;
esac
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜