[plt-scheme] hostname

From: Hans Oesterholt (hdnews at gawab.com)
Date: Mon Apr 18 16:53:13 EDT 2005

Eli Barzilay wrote:

>On Apr 18, Hans Oesterholt wrote:
>  
>
>>Is there a possibility to retreive the hostname of
>>a machine (like 'uname' does) with mzscheme?
>>    
>>
>
>If you're using Linux, then things are relatively easy:
>
>  (with-input-from-file "/proc/sys/kernel/hostname" read-line)
>  
>
This is somewhat 'proc' fs specific...

>If you're using an arbitrary Unix machine, then you should use the
>hostname command:
>
>  (require (lib "process.ss"))
>  (let ([s (open-output-string)])
>    (parameterize ([current-output-port s]) (system "hostname"))
>    (regexp-replace #rx"\n$" (get-output-string s) ""))
>  
>
Ok, fair enough, however, what about Windows?

>but that's a rough version -- you'll need to improve it by catching
>errors etc.
>
>  
>
Of course.



Posted on the users mailing list.