Generator script

Hello again unix.com people,

I need your help again. I'm currently need a script that will generate ip ranges... lets say from 64.1.1.1 to 74.255.255.255 and the output should be like this:

64.1.1.2
64.1.1.3
.............
.............
74.255.255.254
74.255.255.255

(line-by-line)

Thank you again.

Galford D. Weller

Hello Galford

Any attempts from your side yet?
Where and why are you stuck?

Thank you

Did you search these forums as recommended? How about this one?

Hello sir,

I'm really a newbie and I'm stuck at a blank page (lol).

---------- Post updated at 05:20 AM ---------- Previous update was at 05:14 AM ----------

Looks nice but I dont know how to use it.

while IFS=", " read IP1 IP2
  do    BIP1=$((0x$(printf "%02X" ${64//./ })));
        BIP2=$((0x$(printf "%02X" ${74//./ })));
        for ((I=BIP1; I<=BIP2; I++))
          do printf "%d.%d.%d.%d\n" $((I>>24)) $((I>>16&255)) $((I>>8&255)) $((I&255))
          done
  done < range

When I execute it the "range" file is empty. Looks like I using it wrong or something. Like I said I am new and need a little more help. Please bear with me a little more. Thanks!

read reads from stdin, which you can redirect from a file ( with a structure as given in that thread ). If you don't, it reads from your keyboard; so - enter your starting and ending address.

DON'T modify the interior of the script as you did with 64 and 74 .

You mean like this?

./iprange 64.0.0.1 74.255.255.255

Please give me an example.

Run it without the stdin redirection, and then enter the limits on the command line. As given, it is made for reading from a file so it doesn't prompt.

./iprange
64.0.0.1 74.255.255.255

Please be aware that this is quite some range; mayhap you try with narrower limits.

1 Like

Thanks a million. You sir are a really life saver!