I'm trying to write a script that will take as input a network and subnet mask and then ping each host.

I can get it to work fine for any class C address that only increments that last octet. However, I'm kind of stuck on how can I work through larger subnets. Once the last octet hits 255, it would need to increment the third octet and then reset the last to 0.

Any suggestions would be appreciated.

Thanks.

Jason

How about working with the 32 bit binary real representation, I posted conversion functions with IP number strings and real binary numbers as Code Snipet. Also you can prepare real binary mask for subnets.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.