Recall & Review
beginner
What does it mean when a script is interactive?
An interactive script asks the user for information while it runs, instead of running all by itself without stopping.
Click to reveal answer
beginner
How does the
read command in bash make a script interactive?The
read command pauses the script and waits for the user to type something. This input can then be used later in the script.Click to reveal answer
beginner
Why is user input important in scripts?
User input lets scripts do different things depending on what the user wants, making scripts flexible and useful in many situations.
Click to reveal answer
beginner
What happens if a script does not use input commands?
The script runs automatically without stopping, using only the information it already has. It cannot change behavior based on user choices.
Click to reveal answer
beginner
Give an example of a simple interactive bash script.
Example:
#!/bin/bash echo "What is your name?" read name echo "Hello, $name!"This script asks for your name and then greets you.
Click to reveal answer
What command in bash is commonly used to get user input?
✗ Incorrect
The
read command waits for user input and stores it in a variable.Why would you want a script to be interactive?
✗ Incorrect
Interactivity allows the script to get information from the user and act accordingly.
What happens if a script uses no input commands?
✗ Incorrect
Without input commands, the script runs automatically using only the data it has.
Which of these is NOT a reason to make a script interactive?
✗ Incorrect
Automating tasks without user help means non-interactive scripts.
In the example script:
read name, what does name represent?✗ Incorrect
name is a variable that holds what the user types.Explain in your own words why input makes a script interactive.
Think about how a conversation works between you and the script.
You got /3 concepts.
Describe a simple scenario where an interactive script is better than a non-interactive one.
Imagine ordering coffee with or without telling the barista your preferences.
You got /4 concepts.