|
Home > Archive > Unix Programming > August 2004 > Another bask problem
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Another bask problem
|
|
| Billy N. Patton 2004-08-03, 5:53 pm |
| From within my bash script I need to open a file that will have a uniqu
identifier.
/home/bpatton/.fleet_cmd_file.<id#>
When I did this in PERL I used the time function to return the time in
seconds
The ferl functions is described as
Returns the number of non-leap seconds since
whatever time the system considers to be the epoch
(that's 00:00:00, January 1, 1904 for Mac OS, and
It needs to be a unique number/name
--
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, b-patton@ti.com
| |
| Martin Blume 2004-08-03, 5:53 pm |
| "Billy N. Patton" schrieb
> From within my bash script I need to open a file that will have a
> uniqu[e] identifier.
>
> /home/bpatton/.fleet_cmd_file.<id#>
>
> When I did this in PERL I used the time function to return the
> time in seconds
> The ferl functions is described as
> Returns the number of non-leap seconds since
> whatever time the system considers to be the epoch
> (that's 00:00:00, January 1, 1904 for Mac OS, and
>
> It needs to be a unique number/name
>
with GNU date: /home/bpatton/.fleet_cmd_file.`date +%s`
with bash /home/bpatton/.fleet_cmd_file.${RANDOM}
As for the uniqueness, this is left as an exercise to the reader.
HTH. YMMV.
Martin
| |
| William Park 2004-08-03, 5:53 pm |
| Billy N. Patton <b-patton@ti.com> wrote:
> From within my bash script I need to open a file that will have a uniqu
> identifier.
>
> /home/bpatton/.fleet_cmd_file.<id#>
>
> When I did this in PERL I used the time function to return the time in
> seconds
> The ferl functions is described as
> Returns the number of non-leap seconds since
> whatever time the system considers to be the epoch
> (that's 00:00:00, January 1, 1904 for Mac OS, and
>
> It needs to be a unique number/name
Use $$ which is PID, if you want uniqueness while machine is running.
If you want unique name in your filesystem, then
man mktemp
man tempfile
man date
--
William Park <opengeometry@yahoo.ca>
Open Geometry Consulting, Toronto, Canada
| |
| Peter Ammon 2004-08-03, 5:53 pm |
| Billy N. Patton wrote:
> From within my bash script I need to open a file that will have a uniqu
> identifier.
>
> /home/bpatton/.fleet_cmd_file.<id#>
>
> When I did this in PERL I used the time function to return the time in
> seconds
> The ferl functions is described as
> Returns the number of non-leap seconds since
> whatever time the system considers to be the epoch
> (that's 00:00:00, January 1, 1904 for Mac OS, and
>
> It needs to be a unique number/name
>
The time in seconds isn't guaranteed unique (what if you have two
instances of the script running, or the script executes twice within a
second, or the clock gets set back...)
Try uuidgen for something more unique and accessible via bash. A UUID
is usually made from a combination of the hardware MAC address, random
values, and a time value with better than one second resolution.
-Peter
| |
| Rich Grise 2004-08-22, 8:48 pm |
| Martin Blume wrote:
> "Billy N. Patton" schrieb
> with GNU date: /home/bpatton/.fleet_cmd_file.`date +%s`
> with bash /home/bpatton/.fleet_cmd_file.${RANDOM}
>
> As for the uniqueness, this is left as an exercise to the reader.
>
date +%G%j%k%m%S%N
:-)
| |
| Rich Grise 2004-08-22, 8:48 pm |
| Peter Ammon wrote:
> Billy N. Patton wrote:
>
> The time in seconds isn't guaranteed unique (what if you have two
> instances of the script running, or the script executes twice within a
> second, or the clock gets set back...)
>
> Try uuidgen for something more unique and accessible via bash. A UUID
> is usually made from a combination of the hardware MAC address, random
> values, and a time value with better than one second resolution.
>
So! That's where those Doze programmers get those stupid registry entry
values! ;-)
Cheers!
Rich
|
|
|
|
|