2014-12-24 6 views
-2

에서 예기치 않은 파일의 끝이 나는 다음과 같은 오류가 발생합니다 :구문 오류 : bash는 오류

#!/bin/bash 

tput clear 
tput bold 
echo Hello, what is your name? 
read Lol 
sleep 2 
echo HI $Lol 
sleep 3 
echo "SoftManager is a software manager and software updater" 
sleep 3 
echo "Copyright (C) 2014 Winston L" 
sleep 2 
echo "What would you like to do?" 
echo "1. Update" 
echo "2. Install/uninstall software" 
echo "3. Other awesome tools" 
read Pie 

if [[ $Pie == 1 ]]; then 
    echo "What distribution are you running?" 
    echo "1. Debian, 2. Fedora 3. Arch" 
    read Interesting 
    if [[ $Interesting == 1 ]]; then 
     sudo apt-get update -y 
     sudo apt-get upgrade -y -qq -f 
    elif [[ $Interesting == 2 ]]; then 
     sudo yum install fedora-upgrade 
     sudo fedora-upgrade 
    else 
     sudo pacman-mirrors -g 
     sudo yaourt -Syua 
     sudo pacman -Syyu 
     sudo yaourt -Syua 
    fi 

elif [[ $Pie == 2 ]]; then 
    echo "Would you like to install or uninstall software?" 
    echo "1. install, 2. uninstall" 
    read Hai 

    if [[ $Hai == 2 ]]; then 
     echo "What distribution are you running?" 
     echo "1. Debian, 2. Fedora, 3. Arch" 
     read Ice 
     if [[ $Ice == 1 ]]; then 
      echo "Please type the package you want to uninstall" 
      read Unin 
      sudo apt-get remove $Unin 
     elif [[ $Ice == 2 ]]; then 
      echo "Please type the package you want to uninstall" 
      read Pop 
      sudo yum remove $Pop 
     else 
      echo "Please type the package you want to uninstall" 
      read Ins 
      sudo pacman -Rns $Ins 
     fi 

    elif [[ $Hai == 1 ]]; then 
     echo "What distribution are you running?" 
     echo "1. Debian, 2. Fedora, 3. Arch" 
     read Cake 
     if [[ $Cake == 1 ]]; then 
      echo "Please type the package you want to install" 
      read Igloo 
      sudo apt-get install $Igloo 
     elif [[ $Cake == 2 ]]; then 
      echo "Please type the package you want to install" 
      read Test 
      yum install $Test 
     else 
      echo "Please type the package you want to install" 
      read Amaze 
      yaourt $Amaze 
     fi 
    else 
      echo "Invalid option" 
    fi  
else 
    echo "Please choose one of these tools:" 
    echo "1. Download file from Internet" 
    echo "2. Add ppa" 
    read Pirate 
    if [[ $Pirate == 1 ]]; then 
     echo "Please type the link, note that the file will be downloaded to where this script is" 
     read Haha 
     wget $Haha 
    elif [[ $Pirate == 2 ]]; then 
     echo "Please type the ppa:" 
     read Randomis 
     sudo add-apt repository $Randomis 
    else 
     echo "Invalid option" 
fi 

답변

3

닫는 fi이 끝에서 누락되었습니다 여기

syntax error: unexpected end of file.

는 코드입니다.

if [[ $Pie == 1 ]]; then 
    # ... 
elif [[ $Pie == 2 ]]; then 
    # ... 
else 
    # ... 
    if [[ $Pirate == 1 ]]; then 
     # ... 
    elif [[ $Pirate == 2 ]]; then 
     #... 
    else 
     echo "Invalid option" 
    # MISSING "fi" 
fi 
+0

대단히 감사합니다. – Winston

2

두 가지 :

  • 당신은 마지막 else 조항의 끝에 닫는 fi을 놓치고있어.
  • 숫자가 같고 숫자가 ==이 아닌 경우 -eq을 사용하려고합니다. ===은 문자열 용입니다. -eq은 숫자 비교를위한 것입니다.