nerdexam
CompTIA

PT0-003 · Question #17

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'…

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…

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?

Exhibit

PT0-003 question #17 exhibit

Options

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

How the community answered

(23 responses)
  • A
    83% (19)
  • B
    9% (2)
  • C
    4% (1)
  • D
    4% (1)

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 Practice