user12586043
user12586043

Reputation:

Shell Script Unexpected End of File

How this works? sorry i am beginner and find not any tutorial or website to explain this things. When you knowing how find this please tell me, im realy appreciated that.

#!/bin/bash
cd Blur
clear


echo "Rangcheck" 

if grep -w $name ./rangs/exo_users.txt; 
then
    echo "Blur" > "./status/rang.txt"
    ./menu.sh
else
if grep -w $name ./rangs/police_users.txt; 
then
    echo "Police" > "./status/rang.txt"
    ./menu.sh
else
if grep -w $name ./rangs/bank_users.txt; 
then
    echo "Bank" > "./status/rang.txt"
    ./menu.sh
else
if grep -w $name ./rangs/fly_users.txt; 
then
    echo "Fly" > "./status/rang.txt"
    ./menu.sh
else
if grep -w $name ./rangs/userlist.txt; 
then
    echo "User" > "./status/rang.txt"
    ./menu.sh

Upvotes: 1

Views: 21

Answers (1)

that other guy
that other guy

Reputation: 123420

Instead of else..if, use elif, and make sure to terminate if expressions with fi:

#!/bin/bash
cd Blur
clear


echo "Rangcheck" 

if grep -w "$name" ./rangs/exo_users.txt; 
then
    echo "Blur" > "./status/rang.txt"
    ./menu.sh
elif grep -w "$name" ./rangs/police_users.txt; 
then
    echo "Police" > "./status/rang.txt"
    ./menu.sh
elif grep -w "$name" ./rangs/bank_users.txt; 
then
    echo "Bank" > "./status/rang.txt"
    ./menu.sh
fi

Also try shellcheck.net, where you can paste your script to have issues like this pointed out automatically.

Upvotes: 2

Related Questions