mercredi 2 août 2023

Why do I get an error In Accessing File for Bash Code

I Wanted to Make A Game To Just Spend Some Time Improving My Programming Skills.. I Got An Error, I tried Every Thing To Try To Fix It, Is There Any Solution? This is The Code

random=$((1 + $RANDOM % 10))
read -p "Enter A UserName" name
if [ -d $name ]
then
    cd $name
    if [ -d Scores ]
    then
        cd Scores
        else
                mkdir Scores
                cd Scores
                cd ../../
    fi
else
    mkdir $name
    cd $name
    mkdir Scores
    cd Scores
    cd ../../
fi
echo 'enter a random number'
read -p "Enter" r
if [ $r = $random ]
then
        echo 'great' $name
else
        echo 'nope' $name 'the number was' $random
fi

echo 'want to play again(y for play again n for dont play again)'
read m
if [ $m = y ]
then
        chmod +x AnswerDebug.sh
    bash AnswerDebug.sh
elif [ $m = n ]
then
        echo 'end of game'
else
echo 'not an input' $name
fi

The Output Was : The Output

I was programming a game where we have to find a random number. I tried to make a Scoring System but it is unfinished

I expected it to work finely but for some reason the code isn't working The code can't access AnswerDebug.sh(The Name Of The File)




Aucun commentaire:

Enregistrer un commentaire