-2
#!/bin/bash
echo "Do you want to Login or Sign Up?"

read ans

if [ "$ans" = "Sign Up" ]

then
echo "You are creating a account"
echo "Create a Username"
read ipr4
clear
echo "Create a Password"
read pwd
touch $pwd &
touch $ipr4 &
read ip
else
clear
echo "Type in your Username"
read pwed
clear

if [ -f $pwed ]; then
echo "Type in your password"
read pass
clear

if [ -f $pass ]; then
echo "Choose a application (To run the proggramm of your choise just type in the name of the proggramm)"
echo " | Ecryption | Chat | Spamming Chat | Quiz | "
read act
if [ "$act" == "Encryption" ]
then
     echo "Do you want to encrypt or decrypt message (Type in encrypt to encrypt a message in base64. Type in decrypt to decrypt a message that was encrypted in base 64)"
read ans
if [ "$ans" = "encrypt" ]
then

     echo "Please enter your message"
read enc
     echo "Your encrypted message is:"
     echo  -n $enc | base64
    echo "Please enter the message that you want to decipher"
read dec
    echo "Your deciphered message is:"
    echo -n $dec | base64 -D
    echo " "
if [ "$act" == "Chat" ] then
echo "Want to be a the Host (yes/no)"
read y

if [ "$y" ==  "yes" ]
then

clear
echo "Which port"
read port
clear
echo "You are on port: $port"
nc -l $port
else
if [ "$y" == "no" ]
then
clear
echo "Which port do you want to chat on"
read p2
echo "What is the listeners IPv4"
read ipi4
clear
echo "You are chatting to $ipi4 on Port: $p2"
nc $ipi4 $p2
else
if [ "$act" == "Spamming Chat"]
then
clear
echo "Want to be a listener (yes/no)"
read y
if [ "$y" ==  "yes" ]
then
clear
echo "Which port"
read port
clear
echo "You are on port: $port"
echo "Which message do you want to spam"
read spamm
echo "You are chatting to $ipv4 on Port: $p2"
mkfifo fifo_filename
nc -l $p2 <fifo_filename &

exec 3>fifo_filename
while true
do
        echo "$spamm"
        sleep 0.001
done >&3
if [ "$act" == "Quiz" ]
then
clear
  echo "Hello this is a test"
  echo "You will be asked 3 questions and each one has two options to choose from.
There is just one correct answer for each question."

  echo "Q1: Is black a colour (yes or no)"
read q1
if [ "$q1" = "no" ]
then
   q1=1
   echo "Correct,you recieved $q1 point"
else
   q1=0
   echo "Wrong you recieved $q1 points"


  echo "Q2:Who painted the Mona Lisa (Aristotle or Da Vinci)"
read q2
if [ "$q2" = "Da Vinci" ]
then
   q2=1
   echo "Correct you recieved $q2 point"
if [ "q2" -ne "Da Vinci" ]
then
  q2=0
  echo "Wrong you recieved $q2 points"

 echo "You now have $(($q1+$q2)) points"

 echo "Q3:Who invented the seatbelt (Volvo or Porsche)"
if [ "$q3" = "Volvo" ]
then
  q3=1
 echo "Correct you recieved $q3 point"
if [ "$q3" -ne "Volvo" ]
then
 q3=0
 echo "Wrong you unfortunately recieved $q3 points"
sleep 4
clear
sleep 2
echo "Congratulations you scored  $(($q1+$q2+$q3))/3"
fi
fi
fi
else
if [ -f -ne $pass ];then
clear
sleep 2
echo "login failed"
echo "4 fi down"
fi
fi
fi
fi
fi
fi
fi
fi

Таким образом, этот кусок кода должен быть базовой системой, которая позволяет вам использовать несколько программ, встроенных в код. Это всегда дает мне две ошибки синтаксической ошибки, и когда я исправляю код, это дает мне предупреждение о неожиданном конце файла, и это продолжается и продолжается. Может кто-нибудь придумать решение этой проблемы.

1 ответ1

7

Я считаю 17 if s и только 11 fi . Закройте if с помощью fi .

Также сделайте отступ в коде правильно.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками .