ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
are they all on the same subnet eg is it 192.168.2.x where x varies between 1 and 254 or is it just 255 totally random addresses, also does it have to do each address once or can it repeat the same address?
They all are on the same subnet eg is it 192.168.2.x where x varies between 1 and 254
it would be better if it won't repeat the same address.
thanks for the quick reply..
Originally posted by kev82 i dont know how good my random number generation is but it seems to work.
I certainly can imagine that it "seems to work"...
But it will produce much less random numbers when you use another name for "RANDOM" !
Bash has it's own random generator, and it uses the RANDOM variable for this.
Quote:
from "man bash" Shell Variables
The following variables are set by the shell:
[..snip..]
RANDOM Each time this parameter is referenced, a random integer between 0 and 32767 is generated. The sequence of random numbers may be initialized by assigning a value to RANDOM. If RANDOM is unset, it loses its special properties, even if it is subsequently reset.
So when you do:
echo 192.168.2.$(( $RANDOM % 255 ))
its not your number-fiddling producing the randomness, but bash's own random generator !
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.