Question 170
The lab examiner asks for evidence after this assignment: A shell script writes raw command output but needs its first line to include the current hostname from the target host. What is the decisive verification step?
Explanation
Correct Answer
The printed host label matches `hostname -s` without treating it as an executable. This check confirms the expected effect of: Use `host=$(hostname -s)` and `printf 'host=%s\n' "$host"` in the exercise script. It distinguishes the intended result from the original failure mechanism: Command substitution captures a command's standard output as data.
Incorrect Answers
The known present and missing fixture processes produce different status messages. That verifies a separate lab task: A maintenance script must report whether a given process name exists without exiting with a misleading success status. It does not validate the implementation required here: Use `host=$(hostname -s)` and `printf 'host=%s\n' "$host"` in the exercise script.
The output contains one result per unit and no unrequested service is started. That verifies a separate lab task: A service check is intended to poll five named systemd units, but the script uses only the first literal unit. It does not validate the implementation required here: Use `host=$(hostname -s)` and `printf 'host=%s\n' "$host"` in the exercise script.
In a fixture where the first command exits 1, the second command does not run. That verifies a separate lab task: A script invokes two commands on one line with a semicolon and prints success even if the first fails. It does not validate the implementation required here: Use `host=$(hostname -s)` and `printf 'host=%s\n' "$host"` in the exercise script.