nerdexam
CompTIACompTIA

PT0-003 · Question #17

PT0-003 Question #17: Real Exam Question with Answer & Explanation

The correct answer is A: Add do after line 2.. The error occurs because the script is missing the do statement after the for loop declaration. In Bash scripting, do is required to indicate the beginning of the loop's body. Corrected Script: - for i in {1..254} – Iterates through 1 to 254. - do (added after line 2) – Marks the

Submitted by ashley.k· Mar 6, 2026Reconnaissance and enumeration

Question

A penetration tester writes the following script to enumerate a /24 network: The tester executes the script, but it fails with the following error: -bash: syntax error near unexpected token 'ping' Which of the following should the tester do to fix the error?

Options

  • AAdd do after line 2.
  • BReplace {1..254} with $(seq 1 254).
  • CReplace bash with tsh.
  • DReplace $i with ${i}.

Explanation

The error occurs because the script is missing the do statement after the for loop declaration. In Bash scripting, do is required to indicate the beginning of the loop's body. Corrected Script: - for i in {1..254} – Iterates through 1 to 254. - do (added after line 2) – Marks the start of the loop's actions. - ping -c1 192.168.1.$i – Pings each IP in the 192.168.1.0/24 subnet. - done – Closes the loop.

Topics

#shell scripting#bash scripting#network enumeration#script debugging

Community Discussion

No community discussion yet for this question.

Full PT0-003 PracticeBrowse All PT0-003 Questions