fixing system-fqdn

This commit is contained in:
interp 2002-08-26 15:33:22 +00:00
parent 52036a75ad
commit d8c1e7f0ad
2 changed files with 8 additions and 20 deletions

View File

@ -33,24 +33,11 @@
(write-char c)
(loop (read-char fd))))))
;; out from ecm-utilities.scm
;; please tell me if this doesn't work on your system.
(define (system-fqdn)
(let ((sysname (system-name)))
(if (string-index sysname #\.)
sysname
(nslookup-fqdn))))
;; This doesn't work on my system. Probably it is not configured well.
;; Nevertheless, the alternative seems better to me
;(define (nslookup-fqdn)
; (let* ((cmd (format #f "nslookup ~a" (system-name)))
; (raw (string-join (run/strings (nslookup ,(system-name)))))
; (match (string-match "Name: +([-a-zA-Z0-9.]+)" raw)))
; (display raw)
; (match:substring match 1)))
(define (nslookup-fqdn)
(host-info:name (host-info (system-name))))
; another easy alternative:
; (car (run/strings (hostname "--long"))))
(let ((host (host-info (system-name))))
(let loop ((addresses (host-info:addresses host)))
(if (null? addresses)
#f
(or (dns-lookup-ip (car addresses))
(loop (cdr addresses)))))))

View File

@ -637,6 +637,7 @@
sigevents
let-opt
srfi-13
dns
handle-fatal-error)
(files (lib sunet-utilities)))