# Getting hostname from ruby

**URL:** <https://www.ruby-forum.com/t/getting-hostname-from-ruby/99406>\
**Category:** Ruby\
**Created:** [January 31, 2006, 4:14pm UTC](https://www.ruby-forum.com/t/getting-hostname-from-ruby/99406 "2006-01-31T16:14:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![phil\_swenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f17d59/32.png) [@phil\_swenson](https://www.ruby-forum.com/u/phil_swenson)\
**Post date:** [January 31, 2006, 4:14pm UTC](https://www.ruby-forum.com/t/getting-hostname-from-ruby/99406/1 "2006-01-31T16:14:06Z")

</div>

Is there a cleaner way to get the host name from ruby other than  
`hostname`?

phil

---

<div class="post-metadata">

**Author:** ![phil\_swenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f17d59/32.png) [@phil\_swenson](https://www.ruby-forum.com/u/phil_swenson)\
**Post date:** [January 31, 2006, 4:40pm UTC](https://www.ruby-forum.com/t/getting-hostname-from-ruby/99406/2 "2006-01-31T16:40:08Z")

</div>

phil swenson wrote:

> Is there a cleaner way to get the host name from ruby other than  
> `hostname`?

require ‘socket’

hostname = Socket.gethostname

---

<div class="post-metadata">

**Author:** ![phil\_swenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f17d59/32.png) [@phil\_swenson](https://www.ruby-forum.com/u/phil_swenson)\
**Post date:** [January 31, 2006, 5:24pm UTC](https://www.ruby-forum.com/t/getting-hostname-from-ruby/99406/3 "2006-01-31T17:24:19Z")

</div>

I am trying to insert my own data into an FXImage and the setData  
member look just what I need. Unfortunately, regardless of the  
number of parameters I pass it I always get the

test.rb:10:in `setData’: No matching function for overloaded  
‘FXImage\_setData’ (ArgumentError)  
from test.rb:10

I have looked at the swig files but am none the wiser as to what I am  
doing wrong, or if there is a bug here.

The simple test case is below and while this doesn’t achieve anything  
it does demonstrate the point.

I am using FX 1.4.3 running on Mac OSX 10.4 with ruby 1.8.3  
(2005-09-21) [powerpc-darwin8.3.0]

#!/usr/bin/env ruby

require ‘fox14’  
include Fox

application = FXApp.new(“Hello”, “FoxTest”)  
main = FXMainWindow.new(application, “Hello”, nil, nil, DECOR\_ALL)  
@buffer = FXImage.new(application, nil, IMAGE\_KEEP, 640, 480)  
data = [0xff00ff00] \* 640 \* 480  
@buffer.setData(data, 0)

application.create()  
main.show(PLACEMENT\_SCREEN)  
application.run()

Thanks,

Dave.

---

<div class="post-metadata">

**Author:** ![phil\_swenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f17d59/32.png) [@phil\_swenson](https://www.ruby-forum.com/u/phil_swenson)\
**Post date:** [February 1, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/getting-hostname-from-ruby/99406/4 "2006-02-01T23:49:36Z")

</div>

phil swenson wrote:

> Is there a cleaner way to get the host name from ruby other than  
> `hostname`?

16:21:55 [~]: ruby -r socket -e ‘p Socket.gethostname’  
“bond”

Kind regards

```
robert
```
