Another bask problem
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Another bask problem




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Another bask problem  
Billy N. Patton


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-03-04 10: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





[ Post a follow-up to this message ]



    Re: Another bask problem  
Martin Blume


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-03-04 10: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








[ Post a follow-up to this message ]



    Re: Another bask problem  
William Park


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-03-04 10: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





[ Post a follow-up to this message ]



    Re: Another bask problem  
Peter Ammon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-03-04 10: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





[ Post a follow-up to this message ]



    Re: Another bask problem  
Rich Grise


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-04 01:48 AM

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

:-)






[ Post a follow-up to this message ]



    Re: Another bask problem  
Rich Grise


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-23-04 01:48 AM

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






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:34 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register