Check variable

Hi people,

I would like to start a review of my config variable to check whether they have been changed and if not then there is only an echo. If they have been changed to my other commands are executed.

I hope you can help me.

with best regards

JPad

edit:

here my code

if [ "$USER" == "TYPE_YOUR_USERNAME" ]; then
echo "please edit the config"
else 
my commands
fi

I am not sure what your question is? Your code works.

[ ] wants = not ==

but i get a error message

./startscript.sh: 76: [: missing ]
./startscript.sh 80: cd: can't cd to TYPE_YOUR_PATH

and then execute the script my commands

Your conditional script works, (OSX 10.7.5 default terminal):-

Last login: Sun Sep 15 15:34:10 on ttys000
AMIGA:barrywalker~> x="Let it be."
AMIGA:barrywalker~> if [ "$x" == "Let it be." ]; then echo "$x"; else echo "Let it not be."; fi
Let it be.
AMIGA:barrywalker~> if [ "$x" == "Let it not be." ]; then echo "$x"; else echo "Let it not be."; fi
Let it not be.
AMIGA:barrywalker~> _

Your error must be somewhere else and not related to the conditional code you uploaded.

when i try it, then i got this

./startscript.sh mainstall
./startscript.sh: 76: [: missing ]
./startscript.sh: 80: cd: can't cd to TYPE_YOUR_PATH
ManiaPlanetServer is downloading.
No passwordentrie for user �TYPE_YOUR_USERNAME�

ManiaPlanetServer is downloaded.

unzip ManiaPlanet
No passwordentrie for user �TYPE_YOUR_USERNAME�
ManiaPlanet was unpacked
ManiaPlanet is given the correct rights.
chmod: access to �ManiaPlanetServer� not possible: file or directory not found

Ready
Please rename /UserData/Config/dedicated_cfg.default.txt in dedicated_cfg.txt and edit the renamed file.
Push the Startbutton to start ManiaPlanet.

here my code

mainstall)
    if [ "$USER" = "TYPE_YOUR_USERNAME" ] && [ "$SERVER" = "TYPE_YOUR_SCREENAME_MANIAPLANET" ] && [ "$TITLE" = "TYPE_YOUR_TITLE" ] && [ "$PF" = "TYPE_YOUR_PATH" ] && [ "$MAPLIST" = "TYPE_YOUR_MATCHSETTINGS"]; then
    echo "Please edit the config section!!!!"
    exit 1
    else
    cd $PF
    echo "ManiaPlanetServer is downloading."
    su $USER -c "wget http://files.maniaplanet.com/ManiaPlanet2Beta/ManiaPlanetBetaServer_latest.zip"
    echo ""
        sleep 5
        echo "ManiaPlanetServer is downloaded."
        echo ""
        echo "unzip ManiaPlanet"
        su $USER -c "unzip ManiaPlanetBetaServer_latest.zip"
        sleep 5
        echo "ManiaPlanet was unpacked"
        echo "ManiaPlanet is given the correct rights."
        chmod +x ManiaPlanetServer
        echo ""
        echo "Ready"
        echo "Please rename /UserData/Config/dedicated_cfg.default.txt in dedicated_cfg.txt and edit the renamed file."
        echo "Push the Startbutton to start ManiaPlanet."
    fi

;;

greetz JPad

If you are unsure try a simple interactive longhand example first...

On your "if" line which I assume is line 76 there should be a space in the last condition just before "]":-

............&& [ "$MAPLIST" = "TYPE_YOUR_MATCHSETTINGS" ]; then

Example using OSX 10.7.5 default terminal, bash:-

Last login: Sun Sep 15 16:03:38 on ttys000
AMIGA:barrywalker~> x="Let it be."
AMIGA:barrywalker~> if [ "$x" == "Let it not be."]; then echo "$x"; else echo "Let it not be."; fi
-bash: [: missing `]'
Let it not be.
AMIGA:barrywalker~> _

Note the space missing before the "]"...

EDIT:
I have a sneaking suspicion your entire "if" condition might still give rise to your error on line 80.

1 Like

A space is missing before the closing ]

... "TYPE_YOUR_MATCHSETTINGS" ]; then
1 Like

Thank you guys, that was the problem