-1

I'm following along the book "Penetration Testing: A hands-on...." and have hit a road bump in executing this simple bash script.

The script basically looks pings all 254 hosts on the designated network in search of an ICMP reply. I'm writing this in nano and everything looks fine until I hit the ping command. 'ping' isn't changing color or anything, so I assume nano isn't recognizing this as a command. I'm not really sure why. I have no issues pinging IP addresses, but it just doesn't seem to be working within the script.

#!/bin/bash
if [ "$1" == "" ]
then 
echo "Usage: ./pingscript.sh [network]"
echo "example: ./pingscript.sh 192.168.0"
else
for x in 'seq 1 254' ; do
ping -c 1 $1.$x | grep "64 bytes"
done
fi

Why isn't the ping command working? As I mentioned earlier, "ping" doesn't change color within nano. Also, when I run my script, I get the error "ping: 192.168.0.seq: Name or service not known"

Now, I am using the latest version of Kali while the book uses 1.0.6. Any insight is appreciated.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
  • 1
    See [What does ` (backquote/backtick) mean in commands?](https://unix.stackexchange.com/questions/27428/what-does-backquote-backtick-mean-in-commands) – steeldriver Jul 06 '17 at 00:54

1 Answers1

3

Please change this

for x in 'seq 1 254' 

to

for x in `seq 1 254` 

or

for x in $(seq 1 254) 
yw_in_k
  • 198
  • 7