From owner-freebsd-questions@FreeBSD.ORG Mon Jun 16 09:42: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 3BC2D37B404 for ; Mon, 16 Jun 2003 09:42:46 -0700 (PDT) Received: from mailout.informatik.tu-muenchen.de (mailout.informatik.tu-muenchen.de [131.159.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id AF19843FB1 for ; Mon, 16 Jun 2003 09:42:44 -0700 (PDT) (envelope-from barner@in.tum.de) Received: by zi025.glhnet.mhn.de (Postfix, from userid 1000) id E909738021; Mon, 16 Jun 2003 18:42:42 +0200 (CEST) Date: Mon, 16 Jun 2003 18:42:42 +0200 From: Simon Barner To: "Jack L. Stone" Message-ID: <20030616164242.GA529@zi025.glhnet.mhn.de> References: <3.0.5.32.20030616111517.0137e538@sage-one.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <3.0.5.32.20030616111517.0137e538@sage-one.net> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at informatik.tu-muenchen.de 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:42:46 -0000 Hi, > 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....?? Don't know about a shell way to do this, but what about this tiny C program (compile and link with gcc -c -o r.o && gcc -or r.o) #include #include =20 int main (int argc, char *argv[]) { srandomdev(); /* use this on non-BSD systems: srandom(time (0)); */ =09 unsigned int r =3D random () % 99999 +1; printf ("%d\n", r); =09 return r; } Cheers, Simon