B
B
BKYCHblU_TOPTUK2021-10-21 21:21:49
bash
BKYCHblU_TOPTUK, 2021-10-21 21:21:49

Syntax error: "done" unexpected (expecting "fi")?

The problem is this, when you try to execute the script, it gives the error "Syntax error: "done" unexpected (expecting "fi")"
Although the code seems to be written correctly, what's the jamb?
I checked on online editors, they didn’t seem to swear ....

#!/bin/bash
port_launcher=""
port_server=""
path_launcher="/home/mcm/HML/"
path_server="/home/mcm/test_TMS/"
var1=0
while [ $var1 -lt 5 ];
do
    statusL=$(lsof -i :$port_launcher | grep -v 'grep' | head -n 1 | awk '{print $2}')
    statusS=$(lsof -i :$port_server | grep -v 'grep' | head -n 1 | awk '{print $2}')
    if [ "$statusL" = "" ] || [ "$statusS" = "" ]; 
        then 
            if [ "$statusL" = "" ]; 
                then 
                    echo "|L| Start..."
                    date=$(date +%d.%m.%Y——%H:%M)
                    echo -e "\n[$date] |L| —— Proccess with port $port_launcher not found. Start..." >> /home/mcm/CMT/logs/LLogs.txt
                    cd $path_launcher; screen -d -m -S laun sh start.sh;
                    sleep 90
            else 
                echo "|L| Is Running"
            fi
            if [ "$statusS" = "" ]; 
                then 
                    echo "|S| |TMS| Start..."
                    date=$(date +%d.%m.%Y——%H:%M)
                    echo -e "\n[$date] |S| |TMS| —— Proccess with port $port_server not found. Start..." >> /home/mcm/CMT/logs/SLogs.txt
                    cd $path_server; screen -d -m -S serv sh startp.sh;
                    var1=$( $var1 + 1 )
                    sleep 180
            else 
                echo "|S| |TMS| Is Running..."
            fi
    else
        echo "|L| Is Running..."
        echo "|S| Is Running..."
        break
    fi
done

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question