unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* OS X (or other OS's): how to get a fully-qualified domain name?
@ 2004-07-26 21:59 John Owens
  0 siblings, 0 replies; 13+ messages in thread
From: John Owens @ 2004-07-26 21:59 UTC (permalink / raw)


Greetings, I'm using emacs 21.3.50 (built from CVS)
on OS X 10.3. I would like it to use a fully-qualified 
domain name when sending mail. Instead, it uses
system-name, which appears to just use my 
"computer name" (which is no way fully-qualified).

What would be ideal is if I could use the system-name
function to dynamically return where I am (since 
if I run emacs at home, then go to work, plug it in, and
use emacs there, I'd like emacs to use the work 
machine's domain name, not the one from home). I
figure that OS X knows its domain name (I can see it 
in the logs if I ssh somewhere, for instance), but I don't
know how to get that information nor do I know 
how to make emacs use it.

Suggestions?

JDO

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
       [not found] <mailman.1622.1090879447.1960.help-gnu-emacs@gnu.org>
@ 2004-07-26 23:11 ` Kevin Rodgers
  2004-07-26 23:59   ` John Owens
       [not found]   ` <mailman.1631.1090886583.1960.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Kevin Rodgers @ 2004-07-26 23:11 UTC (permalink / raw)


John Owens wrote:
 > Greetings, I'm using emacs 21.3.50 (built from CVS) on OS X 10.3. I
 > would like it to use a fully-qualified domain name when sending
 > mail. Instead, it uses system-name, which appears to just use my
 > "computer name" (which is no way fully-qualified).
 >
 > What would be ideal is if I could use the system-name function to
 > dynamically return where I am (since if I run emacs at home, then go
 > to work, plug it in, and use emacs there, I'd like emacs to use the
 > work machine's domain name, not the one from home). I figure that OS X
 > knows its domain name (I can see it in the logs if I ssh somewhere,
 > for instance), but I don't know how to get that information nor do I
 > know how to make emacs use it.

C-h v user-mail-address
C-h v mail-host-address

To get the domain name in Emacs on Unix, try this:

(shell-command-to-string "awk '/^domain/ {printf $2}' /etc/resolv.conf")

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
  2004-07-26 23:11 ` Kevin Rodgers
@ 2004-07-26 23:59   ` John Owens
       [not found]   ` <mailman.1631.1090886583.1960.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: John Owens @ 2004-07-26 23:59 UTC (permalink / raw)


Kevin Rodgers <ihs_4664 <at> yahoo.com> writes:
> John Owens wrote:
>  > What would be ideal is if I could use the system-name function to
>  > dynamically return where I am (since if I run emacs at home, then go
>  > to work, plug it in, and use emacs there, I'd like emacs to use the
>  > work machine's domain name, not the one from home).
> 
> C-h v user-mail-address
> C-h v mail-host-address

Unfortunately, neither of these is dynamic (at least I don't think so - I
just set them statically in .emacs).

> To get the domain name in Emacs on Unix, try this:
> 
> (shell-command-to-string "awk '/^domain/ {printf $2}' /etc/resolv.conf")

Also unfortunately, OS X doesn't give a FQDN (in mine, it just says sbcglobal.net
which is my domain but not my hostname).

Any thoughts on doing any of this dynamically? 

JDO

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
       [not found]   ` <mailman.1631.1090886583.1960.help-gnu-emacs@gnu.org>
@ 2004-07-27  1:22     ` Barry Margolin
  2004-07-27  1:37       ` John Owens
       [not found]       ` <mailman.1641.1090892436.1960.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Barry Margolin @ 2004-07-27  1:22 UTC (permalink / raw)


In article <mailman.1631.1090886583.1960.help-gnu-emacs@gnu.org>,
 John Owens <john_owens@yahoo.com> wrote:

> Kevin Rodgers <ihs_4664 <at> yahoo.com> writes:
> > John Owens wrote:
> >  > What would be ideal is if I could use the system-name function to
> >  > dynamically return where I am (since if I run emacs at home, then go
> >  > to work, plug it in, and use emacs there, I'd like emacs to use the
> >  > work machine's domain name, not the one from home).
> > 
> > C-h v user-mail-address
> > C-h v mail-host-address
> 
> Unfortunately, neither of these is dynamic (at least I don't think so - I
> just set them statically in .emacs).
> 
> > To get the domain name in Emacs on Unix, try this:
> > 
> > (shell-command-to-string "awk '/^domain/ {printf $2}' /etc/resolv.conf")
> 
> Also unfortunately, OS X doesn't give a FQDN (in mine, it just says 
> sbcglobal.net
> which is my domain but not my hostname).
> 
> Any thoughts on doing any of this dynamically? 

It's pretty unusual to want to put the machine name in your email 
address.  Are you sure this is what you really want?

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
  2004-07-27  1:22     ` Barry Margolin
@ 2004-07-27  1:37       ` John Owens
       [not found]       ` <mailman.1641.1090892436.1960.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: John Owens @ 2004-07-27  1:37 UTC (permalink / raw)


Barry Margolin <barmar <at> alum.mit.edu> writes:
> It's pretty unusual to want to put the machine name in your email 
> address.  Are you sure this is what you really want?

All I really want it for is generating message-IDs, which need
to be globally unique. Right now generating message-IDs uses
system-name by default, but system-name doesn't include the domain
name and is thus not globally unique.

JDO

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
       [not found]       ` <mailman.1641.1090892436.1960.help-gnu-emacs@gnu.org>
@ 2004-07-27 15:16         ` Stefan Monnier
  2004-07-27 17:03           ` John Owens
       [not found]           ` <mailman.1759.1090947989.1960.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Stefan Monnier @ 2004-07-27 15:16 UTC (permalink / raw)


>> It's pretty unusual to want to put the machine name in your email 
>> address.  Are you sure this is what you really want?

> All I really want it for is generating message-IDs, which need
> to be globally unique. Right now generating message-IDs uses
> system-name by default, but system-name doesn't include the domain
> name and is thus not globally unique.

Than how about setting system-name to something unique?


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
  2004-07-27 15:16         ` Stefan Monnier
@ 2004-07-27 17:03           ` John Owens
       [not found]           ` <mailman.1759.1090947989.1960.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: John Owens @ 2004-07-27 17:03 UTC (permalink / raw)


Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> > All I really want it for is generating message-IDs, which need
> > to be globally unique. Right now generating message-IDs uses
> > system-name by default, but system-name doesn't include the domain
> > name and is thus not globally unique.
> 
> Than how about setting system-name to something unique?

I think that's what I'm stuck with, and I can readily use the unique hostname
of my laptop when it's plugged into my campus network. The most common
message-IDs I see, however, use the place from where the message was sent,
so I was hoping to do that. No easy answers on doing so, though, so I'll
fall back to using my hostname from work.

Thanks for all the nice replies.

JDO

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
       [not found]           ` <mailman.1759.1090947989.1960.help-gnu-emacs@gnu.org>
@ 2004-07-27 18:06             ` Stefan Monnier
  2004-07-27 18:29               ` John Owens
       [not found]               ` <mailman.1770.1090954587.1960.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 13+ messages in thread
From: Stefan Monnier @ 2004-07-27 18:06 UTC (permalink / raw)


>> > All I really want it for is generating message-IDs, which need
>> > to be globally unique. Right now generating message-IDs uses
>> > system-name by default, but system-name doesn't include the domain
>> > name and is thus not globally unique.
>> 
>> Than how about setting system-name to something unique?

> I think that's what I'm stuck with, and I can readily use the unique hostname
> of my laptop when it's plugged into my campus network. The most common
> message-IDs I see, however, use the place from where the message was sent,
> so I was hoping to do that. No easy answers on doing so, though, so I'll
> fall back to using my hostname from work.

The Message-ID can use anything you want, so long as it obeys similar
constraints to the ones applied to host names.
I'd guess that youremail@address plus some time-dependent string is
sufficient for uniqueness since noone else will use youremail@address even
on some other machine.

I personally use monnier@gnu.org in my Message-ID (plus some stuff to keep
track of newsgroup&folder where I sent things from, to help me file replies)
even though I never send email from a gnu machine.


        Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
  2004-07-27 18:06             ` Stefan Monnier
@ 2004-07-27 18:29               ` John Owens
       [not found]               ` <mailman.1770.1090954587.1960.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 13+ messages in thread
From: John Owens @ 2004-07-27 18:29 UTC (permalink / raw)


Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> The Message-ID can use anything you want, so long as it obeys similar
> constraints to the ones applied to host names.
> I'd guess that youremail <at> address plus some time-dependent string is
> sufficient for uniqueness since noone else will use youremail <at> address even
> on some other machine.

And I think that's my best bet ... thanks to all for the advice on this.

This does bring up the larger point, however, that there might be circumstances
where emacs DOES need to know its fully qualified domain name, and there does
not seem to be a way to get it, which is unfortunate.

JDO

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
       [not found]               ` <mailman.1770.1090954587.1960.help-gnu-emacs@gnu.org>
@ 2004-07-27 19:46                 ` Stefan Monnier
  2004-07-27 20:30                   ` John Owens
  2004-07-27 19:48                 ` Kevin Rodgers
  1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2004-07-27 19:46 UTC (permalink / raw)


> This does bring up the larger point, however, that there might be
> circumstances where emacs DOES need to know its fully qualified domain
> name, and there does not seem to be a way to get it, which is unfortunate.

But this is *very* rare.  And for good reasons: it's not really clear what
it means.  A machine can have:
- no fully qualified name (if you're not connected to the net).
- 1 FQDN
- several different FQDN (using only one IP address or using several IP
  addresses via a single network interface, or over several network
  interfaces, ...).


-- Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
       [not found]               ` <mailman.1770.1090954587.1960.help-gnu-emacs@gnu.org>
  2004-07-27 19:46                 ` Stefan Monnier
@ 2004-07-27 19:48                 ` Kevin Rodgers
  2004-07-27 20:49                   ` John Owens
  1 sibling, 1 reply; 13+ messages in thread
From: Kevin Rodgers @ 2004-07-27 19:48 UTC (permalink / raw)


John Owens wrote:
 > This does bring up the larger point, however, that there might be
 > circumstances where emacs DOES need to know its fully qualified domain
 > name, and there does not seem to be a way to get it, which is
 > unfortunate.

Emacs does try to get the FQDN from the system; see the init_system_name
function in src/sysdep.c.

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
  2004-07-27 19:46                 ` Stefan Monnier
@ 2004-07-27 20:30                   ` John Owens
  0 siblings, 0 replies; 13+ messages in thread
From: John Owens @ 2004-07-27 20:30 UTC (permalink / raw)


Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> > This does bring up the larger point, however, that there might be
> > circumstances where emacs DOES need to know its fully qualified
> > domain name, and there does not seem to be a way to get it,
> > which is unfortunate.
> 
> But this is *very* rare.  And for good reasons: it's not really clear what
> it means.  A machine can have:
> - no fully qualified name (if you're not connected to the net).
> - 1 FQDN
> - several different FQDN (using only one IP address or using several IP
>   addresses via a single network interface, or over several network
>   interfaces, ...).

Understood; first, I can't think of a circumstance where emacs might
*really* need to know this. But in case it did, it would be nice if it would
at least make a best effort. If it has none, well, it fails. If it has one or
more, it returns one valid one. I'm just thinking as a programmer, if I
wanted to use a FQDN name, having emacs at least make a good effort
toward finding one would be desirable. And in OS X's case, it isn't
making a particularly good effort.

None of this makes any difference for the problem I'm looking at; the
suggestion to just use the work hostname and to hardcode it will work
just fine for what I want. I'm more interested (at this point) in "what
should system-name return in the ideal case"; for me, a best-effort
toward a FQDN would be desirable.

JDO

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: OS X (or other OS's): how to get a fully-qualified domain name?
  2004-07-27 19:48                 ` Kevin Rodgers
@ 2004-07-27 20:49                   ` John Owens
  0 siblings, 0 replies; 13+ messages in thread
From: John Owens @ 2004-07-27 20:49 UTC (permalink / raw)


Kevin Rodgers <ihs_4664 <at> yahoo.com> writes:
> Emacs does try to get the FQDN from the system; see the init_system_name
> function in src/sysdep.c.

It's calling gethostname, and gethostname on OS X just doesn't seem to 
try particularly hard. From a brief experiment, it appears to give a FQDN
when I'm on a static IP, but once my IP becomes a dynamic one (through a
wireless router), it reverts to the non-FQDN name of the machine. Ah well.
Does not appear to be an emacs problem but instead a OS X problem.
(sysctl does not do any better.)

JDO

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-07-27 20:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-26 21:59 OS X (or other OS's): how to get a fully-qualified domain name? John Owens
     [not found] <mailman.1622.1090879447.1960.help-gnu-emacs@gnu.org>
2004-07-26 23:11 ` Kevin Rodgers
2004-07-26 23:59   ` John Owens
     [not found]   ` <mailman.1631.1090886583.1960.help-gnu-emacs@gnu.org>
2004-07-27  1:22     ` Barry Margolin
2004-07-27  1:37       ` John Owens
     [not found]       ` <mailman.1641.1090892436.1960.help-gnu-emacs@gnu.org>
2004-07-27 15:16         ` Stefan Monnier
2004-07-27 17:03           ` John Owens
     [not found]           ` <mailman.1759.1090947989.1960.help-gnu-emacs@gnu.org>
2004-07-27 18:06             ` Stefan Monnier
2004-07-27 18:29               ` John Owens
     [not found]               ` <mailman.1770.1090954587.1960.help-gnu-emacs@gnu.org>
2004-07-27 19:46                 ` Stefan Monnier
2004-07-27 20:30                   ` John Owens
2004-07-27 19:48                 ` Kevin Rodgers
2004-07-27 20:49                   ` John Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).