Re: How can I get a random number in a UNIX shell script???
From: Ernst Lippe (ernstl-at-planet-dot-nl@ignore.this)
Date: 04/18/03
- Next message: scriptOmatic: "Re: How can I get a random number in a UNIX shell script???"
- Previous message: Paul Floyd: "Re: STL for SolarisCC4.2"
- In reply to: Dr. David Kirkby: "How can I get a random number in a UNIX shell script???"
- Next in thread: scriptOmatic: "Re: How can I get a random number in a UNIX shell script???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Ernst Lippe" <ernstl-at-planet-dot-nl@ignore.this> Date: Fri, 18 Apr 2003 23:01:34 +0200
On Fri, 18 Apr 2003 18:39:42 +0100, Dr. David Kirkby wrote:
> I've written a UNIX shell script
> http://www.medphys.ucl.ac.uk/~davek/teston
>
> that allows me to copy a software package to a remote machine, then
> try to configure and build the software on that remote host. So I
> might do something like this, to check package package-foo.tar.gz on 3
> machines with 4 different configuration options, with the -T option
> saying to do this is a unique directory.
>
> teston host1 -T package-foo
> teston host1 -c '--with-threads' -T package-foo
> teston host1 -c '--with-mpi' -T package-foo
> teston host1 -c '--without-gsl' -T package-foo
>
> teston host2 -T package-foo
> teston host2 -c '--with-threads' -T package-foo
> teston host2 -c '--with-mpi' -T package-foo
> teston host2 -c '--without-gsl' -T package-foo
>
> teston host3 -T package-foo
> teston host3 -c '--with-threads' -T package-foo
> teston host3 -c '--with-mpi' -T package-foo
> teston host3 -c '--without-gsl' -T package-foo
>
> so package-foo.tar.gz gets configure/built on 3 hosts, with 4
> different options to the configure script, in ****hopefully**** 4
> different directories on each host.
>
> My problem is that I need to put each set of file into a separate
> directory, as otherwise they mess each other up. Currently I'm using
> as a directory $HOME/$REMOTE_HOSTNAME/$PID, where $PID is the PID on
> the local machine from where this is started. There is no risk of
> files from host1 interfering with those of host2, since they are in
> different directories. But there is nothing preventing those with each
> different configuration option screwing each other up on the same
> host, as I can't guarantee the PIDs will be different each time.
>
> Hence I want a random number that is portable, so not relying on perl
> or /dev/random. It doesn't need to by crytograpically secure, but
> hopefully the risk of it producing the same number on the one system
> is very small (say < 1 in 10^5).
Why do you want to use a random number?
It seems much safer to use something like dir1, dir2 etc.
Before creating the directory you should check what the
the first free number is.
Another trick that should work in almost all cases is
to base the directory name on the current date and time
plus the PID of the process on the remote machine.
Unless the clock of that machine has serious problems
this should work in most cases.
greetings,
Ernst Lippe
- Next message: scriptOmatic: "Re: How can I get a random number in a UNIX shell script???"
- Previous message: Paul Floyd: "Re: STL for SolarisCC4.2"
- In reply to: Dr. David Kirkby: "How can I get a random number in a UNIX shell script???"
- Next in thread: scriptOmatic: "Re: How can I get a random number in a UNIX shell script???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|