#!/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
我数了数,17 个if
s,只有 11 个fi
s。if
用fi
s 结束 s。
还要适当缩进代码。