Build Five Programs - Build Five Programs

Tell us what’s happening:

this test is not passing
instruction:

after Add commands to run the rest of your scripts in the file. They should be in this order: questionnaire, countdown, bingo, and fortune. Don’t forget that your countdown.sh file needs an argument, so put a 3 next to it.

here is a picture of what is failing with the error:

//five.sh

#!/bin/bash

# Program to run my other four programs

./questionnaire.sh

./countdown.sh 3

./bingo.sh

./fortune.sh

//bingo.sh

#!/bin/bash

# Bingo Number Generator

echo -e "\n~~ Bingo Number Generator ~~\n"

NUMBER=$(( RANDOM % 75 +1 ))

TEXT="The next number is, "

if (( $NUMBER <= 15 ))

then 

echo $TEXT B:$NUMBER

elif [[ $NUMBER -le 30 ]]

then 

  echo $TEXT I:$NUMBER

elif (( $NUMBER < 46 ))

then 

  echo $TEXT N:$NUMBER

elif [[ $NUMBER -lt 61 ]]

then 

echo $TEXT G:$NUMBER

else

 echo $TEXT O:$NUMBER

fi

//countdown.sh

#!/bin/bash

# Program that counts down to zero from a given argument

echo -e "\n~~ Countdown Timer ~~\n"

if [[ $1 -ge 0 ]]

then

 : ' for (( i = $1; i >= 0; i--)) 

  do 

    echo $i

    sleep 1

  done '

  I=$1

  while [[ $I -ge 0 ]]

  do 

    echo $I

    (( I-- ))

     sleep 1

  done

else

  echo Include a positive integer as the first argument.

fi


//fortune.sh

#!/bin/bash

# Program to tell a person's fortune

echo -e "\n~~ Fortune Teller ~~\n"

RESPONSES=("Yes" "No" "Maybe" "Outlook good" "Don't count on it" "Ask again later")

GET_FORTUNE() {

  if [[ ! $1 ]]; then

    echo "Ask a yes or no question:"

  else

    echo "Try again. Make sure it ends with a question mark:"

  fi

  read QUESTION

}

GET_FORTUNE

until [[ $QUESTION =~ \?$ ]]; do

  GET_FORTUNE again

done

N=$(( RANDOM % 6 ))

echo -e "\n${RESPONSES[$N]}"

questionnaire.sh

#!/bin/bash

echo -e "\n~~ Questionnaire ~~\n"

QUESTION1="What's your name?"

echo $QUESTION1

read NAME

echo Hello $NAME.

QUESTION2="Where are you from?"

echo $QUESTION2

read LOCATION

echo Hello $NAME from $LOCATION.

QUESTION3="What's your favorite coding website?"

echo $QUESTION3

read WEBSITE

echo -e "\nHello $NAME from $LOCATION. I learned that your favorite coding website is $WEBSITE!"

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Challenge Information:

Build Five Programs - Build Five Programs

Github Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-bash-five-programs/5f5904ac738bc2fa9efecf5a.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @Telzeez

Please share a screen grab of the full terminal.

Happy coding

I suggest clicking Reset, then waiting for it to reset the step - be patient - and then take a screen shot of the whole vs code area (the whole window). Then make the coding changes and take another screenshot. Show us both.

(Also try putting a blank line at the last line of the file)

ok thanks will try that

is this screen shot before or after the changes? We don’t need to see all the files if you are only touching one file for this step.
(So I’d like to see the screen with the file you are modifying -before- you modify it and -after- you modify it. Ideally the screen also displays the current instructions. Basically, help me see what you are currently looking at and what you are doing so I can understand what went wrong)

before

after

can you click on the OUTPUT tab (2nd menu item to the left of your TERMINAL menu) and once there, look on the right hand side of the terminal for a drop down box. Click it and choose CodeRoad from the list there.
Then click Run button.
Please report back what errors are shown.

Hi @Telzeez

At the top of the fortune script, replace the second comment with this one:

#Program to tell a persons fortune

Happy coding

FAILED TEST LOG

✘ Your script should have the suggested commands added correctly

Error: Command failed: ./.freeCodeCamp/test.sh

at ChildProcess.exithandler (node:child_process:422:12)

at ChildProcess.emit (node:events:517:28)

at maybeClose (node:internal/child_process:1098:16)

at Socket. (node:internal/child_process:450:11)

at Socket.emit (node:events:517:28)

at Pipe. (node:net:350:12)

Thanks, but still fails

Are you sure the only modification you made after clicking reset is to add the new lines of code and nothing else?

The test seems to be looking for something and not finding it.

My next action would be to open the test file that is running and read through it to see what it is failing to find. Do you know enough now to try this yourself?

Also worth trying: go to the test.sh parent path mentioned and try to run it yourself in the terminal. I would be interested in its output and compare that to the test.sh code itself to figure out what has failed.

Thanks the test now passed

Good to hear this. What was the issue?

I had to reset the lesson saverally due to the stale test environment and waited patiently. Also blank lines issue in the ./fortune.sh