Create Unique Message-ID

Create Unique Message-ID

am 22.06.2007 12:45:45 von yig

Hi,
I've scoured google for this, and have found lots of possible solutions,
but none seems to work.

I'm trying to create a unique Message-ID that will go in the top of a
Usenet post. So obviously, each ID has to be unique, and I did this once
before, but can't remember how. I think I did my $id = `date`; or
something and then when it came to creating the header, it was
$message_id=$id, "@yahoo.fr" or something.

The problem is that `date`generates the date in .. well, in the wrong
format. I need it in like say just seconds. So I can have unique IDs like
"9283736663616@yahoo.fr" or something.

Help!

Re: Create Unique Message-ID

am 22.06.2007 13:37:40 von paduille.4061.mumia.w+nospam

On 06/22/2007 05:45 AM, yig wrote:
> Hi,
> I've scoured google for this, and have found lots of possible solutions,
> but none seems to work.
>
> I'm trying to create a unique Message-ID that will go in the top of a
> Usenet post. So obviously, each ID has to be unique, and I did this once
> before, but can't remember how. I think I did my $id = `date`; or
> something and then when it came to creating the header, it was
> $message_id=$id, "@yahoo.fr" or something.
>
> The problem is that `date`generates the date in .. well, in the wrong
> format. I need it in like say just seconds. So I can have unique IDs like
> "9283736663616@yahoo.fr" or something.
>
> Help!
>
>

I don't think you should use @yahoo.fr unless you're the company Yahoo
in France.

Anyway, Perl's time() function returns the time in seconds since an epoch.

#!/usr/bin/perl
print time() . '@mydomian.example.com';


__HTH__

Re: Create Unique Message-ID

am 22.06.2007 16:35:29 von yig

Mumia W. wrote:
> On 06/22/2007 05:45 AM, yig wrote:
>> Hi,
>> I've scoured google for this, and have found lots of possible solutions,
>> but none seems to work.
>>
>> I'm trying to create a unique Message-ID that will go in the top of a
>> Usenet post. So obviously, each ID has to be unique, and I did this once
>> before, but can't remember how. I think I did my $id = `date`; or
>> something and then when it came to creating the header, it was
>> $message_id=$id, "@yahoo.fr" or something.
>>
>> The problem is that `date`generates the date in .. well, in the wrong
>> format. I need it in like say just seconds. So I can have unique IDs like
>> "9283736663616@yahoo.fr" or something.
>>
>> Help!

> I don't think you should use @yahoo.fr unless you're the company Yahoo
> in France.

You're quite right, of course. My bad.

> Anyway, Perl's time() function returns the time in seconds since an epoch.
>
> #!/usr/bin/perl
> print time() . '@mydomian.example.com';
> > __HTH__

It does: many thanks.

Re: Create Unique Message-ID

am 22.06.2007 21:23:34 von Joe Smith

yig wrote:

> I'm trying to create a unique Message-ID that will go in the top of a
> Usenet post. So obviously, each ID has to be unique,

I would use an ID that includes the time, includes a counter (in case more
than one message per second), includes the process-ID (in case multiple
instances running at the same time), and includes the host name (required).

my $hostname = 'yahoo-fr.example.com';
for (my $count = 0;; ++$count) {
my $message_id = time() . ".$count.$$.$domain";
send_message($message_id);
}

-Joe

Re: Create Unique Message-ID

am 23.06.2007 22:36:09 von rvtol+news

Joe Smith schreef:
> yig:

>> I'm trying to create a unique Message-ID that will go in the top of a
>> Usenet post. So obviously, each ID has to be unique,
>
> I would use an ID that includes the time, includes a counter (in case
> more than one message per second), includes the process-ID (in case
> multiple instances running at the same time), and includes the host
> name (required).
>
> my $hostname = 'yahoo-fr.example.com';
> for (my $count = 0;; ++$count) {
> my $message_id = time() . ".$count.$$.$domain";
> send_message($message_id);
> }

ITYM: my $message_id = time() . ".$count.$$\@$hostname";

You could reset $count when time() has changed.

my $hostname = 'yahoo-fr.example.com';

my $time = time;

my $count = 0;

for my $msg (@messages) {
++$count;
$msg->message_id( qq{$time.$count.$$\@$hostname} );
if ( (my $t = time) != $time ) {
$time = $t;
$count = 0;
}
}

--
Affijn, Ruud

"Gewoon is een tijger."