cloudytechi147
New Member
I'm working on a Linux course and using the best Linux OS, the instructor uses a ping-sweeping function as an example. It is meant to iterate through potential IPs on a network from 1 through 255 and return the ones that reply. The code is as follows
This is within a file called ipsweep.sh, which we then call with
When I run the script, I get the result
So what I assume is it's not reading seq as a function and simply hitting it and trying to throw it into my script as-is. Obviously, an IP like 192.168.1.seq doesn't exist so we run into this.
I don't fully understand the syntax of the sequence function because I'm new to Linux and scripting in general, but I've tried using
instead but the script won't recognize the parenthesis. Essentially I just need to know how to get the 'seq 1 254' function to work. Any help is greatly appreciated!!
Code:
#!/bin/bash
for ip in 'seq 1 254'; do
ping -c 1 $1.$ip | grep "64 bytes" | cut -d " " -f 4 | tr -d ":" &
done
This is within a file called ipsweep.sh, which we then call with
Code:
./ipsweep.sh [first three tuples of IP]
When I run the script, I get the result
Code:
ping: [myIP].seq: Name or service not known
So what I assume is it's not reading seq as a function and simply hitting it and trying to throw it into my script as-is. Obviously, an IP like 192.168.1.seq doesn't exist so we run into this.
I don't fully understand the syntax of the sequence function because I'm new to Linux and scripting in general, but I've tried using
Code:
for ip in (seq 1 254); do
instead but the script won't recognize the parenthesis. Essentially I just need to know how to get the 'seq 1 254' function to work. Any help is greatly appreciated!!