From owner-freebsd-questions@FreeBSD.ORG Mon Jun 16 09:32:46 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BA4A137B401 for ; Mon, 16 Jun 2003 09:32:46 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id E6A5543FBF for ; Mon, 16 Jun 2003 09:32:44 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) h5GGWZcm033820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Jun 2003 17:32:42 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)h5GGWZEb033819; Mon, 16 Jun 2003 17:32:35 +0100 (BST) (envelope-from matthew) Date: Mon, 16 Jun 2003 17:32:35 +0100 From: Matthew Seaman To: "Jack L. Stone" Message-ID: <20030616163235.GB33582@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , "Jack L. Stone" , freebsd-questions@freebsd.org References: <3.0.5.32.20030616111517.0137e538@sage-one.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tsOsTdHNUZQcU9Ye" Content-Disposition: inline In-Reply-To: <3.0.5.32.20030616111517.0137e538@sage-one.net> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-7.0 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_MUTT version=2.55 X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) cc: freebsd-questions@freebsd.org Subject: Re: Running a rand or random script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jun 2003 16:32:47 -0000 --tsOsTdHNUZQcU9Ye Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 16, 2003 at 11:15:17AM -0500, Jack L. Stone wrote: > I need to run a script, perhaps using FBSD's 'rand' or 'random' command (= or > any other) that will generate one single 5-digit number 'at random' betwe= en > 00001-99999 >=20 > Anyone have thoughts on how to do this....?? perl -e 'printf "%0.5d\n", int(rand(99999) + 1);' Assuming that range is inclusive. Cheers, Matthew Nb. Don't use srand() explicitly --- perl will auto-seed the PRNG from /dev/urandom if left to it's own devices. --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --tsOsTdHNUZQcU9Ye Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQE+7fEjdtESqEQa7a0RAgs4AJ9JuF8rU8mKF3tgrsuNnqgfr5cYPwCdF7FK vFSr/G+kM5LeO/WBe29Y3Qk= =+bwE -----END PGP SIGNATURE----- --tsOsTdHNUZQcU9Ye--