I am writing a bash script for html form. I have two issues which I can't seem to be able to figure out. I am a beginner to Unix.
First problem is that I can't get my if statement to work while using command as condition. I am trying to check user input of middle initial and adjust it to make sure it can be combined into $answer.
#! /bin/bash
echo Content-type: "text/html"
echo ""
read input #name variable $first, $middle, $last name
first=`user input`
middle=`user input`
last=`user input`
president=`actual answer, full name of president`
answer=`user answer, combination of $first, $middle, $last`
correctF=`actual first name from $president`
correctM=`actual middle initial from $president`
correctL=`actual last name from $president`
#cut by column from $president
First problem starts here.
if [[ $(echo $middle | wc -l) = 1 ]] ; then
    middle=`echo "$middle""."` 
    #check if middle initial variable was entered with just the letter and place a period after
elif [[ $(echo $middle | grep '.') = 'true' ]] ; then
    middle=`echo "$middle"`
    #check if middle initial variable was entered with the period and leave it as is
else
    middle=`'false'`
    #no middle initial variable was entered and is null
fi
Second problem in while loop with if statement.
I am trying to compare the user input $answer to actual answer $president and echo what is wrong with $answer. Nothing is echoed for this section.
while [ "$president" -ne "$answer" ] #not working
    do
            if [ "$first" -ne "$correctF" ]
                    then
                            echo "Wrong first name!"
            elif [ "$middle" -ne "$correctM" ]
                    then
                            echo "Wrong middle initial!"
            elif [ "$last" -ne "$correctL" ]
                    then
                            echo "Wrong last name!"
            elif [ -z "$middle" -ne "$correctM" ]
                    then
                            echo "No middle initial!"
            elif [ "$first" -ne "$correctF" ] && [ "$last" -ne "$correctL" ]
                    then
                            echo "Wrong first and last name!"
            elif [ "$first" -ne "$correctF" ] && [ "$middle" -ne "$correctM" ]
                    then
                            echo "Wrong first name and middle initial!"
            elif [ "$middle" -ne "$correctM" ] && [ "$last" -ne "$correctL" ]
                    then
                            echo "Wrong middle initial and last name!"
            elif [ "$first" -ne "$correctF" ] && [ "$middle" -ne "$correctM"] && [ "$last" -ne "$correctL" ]
                    then
                            echo "You got it all wrong!"
                    else
                            echo "You are correct!"
            fi
I've googled, searched and tried many different examples but I am not able to find a solution.
If someone can guide me on how to properly implement command into if statement condition and write if statement with multiple conditions, I would very much appreciate it.