Hi, I have written an rake task where I need to access “Hostname” . I need this feature because I will be testing my application using the rake task both locally and on live server . I found code in another language which does the same hostname = os.environ.get(''HOSTNAME'') puts "hostname =" + hostname Is there anything similar to the above code in rails which I can use in my application . Thanks, Madhu Nallamani --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, If you''re using unix, you could do: hostname = `hostname` puts "hostname = #{hostname}" The backquotes simply execute the text inside them at a unix shell. Julian. Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #4 parts a and b now available! http://sensei.zenunit.com/ On 10/05/2008, at 2:41 AM, Nallamani wrote:> > Hi, > > I have written an rake task where I need to access “Hostname” . I need > this feature because I will be testing my application using the rake > task both locally and on live server . > > I found code in another language which does the same > > hostname = os.environ.get(''HOSTNAME'') > > puts "hostname =" + hostname > > Is there anything similar to the above code in rails which I can use > in my application . > > Thanks, > Madhu Nallamani > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
try: Socket.gethostname You may need to require the socket library first. Jamey On Fri, May 9, 2008 at 12:41 PM, Nallamani <padmamadhukar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I have written an rake task where I need to access "Hostname" . I need > this feature because I will be testing my application using the rake > task both locally and on live server . > > I found code in another language which does the same > > hostname = os.environ.get(''HOSTNAME'') > > puts "hostname =" + hostname > > Is there anything similar to the above code in rails which I can use > in my application . > > Thanks, > Madhu Nallamani > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Jamey and Julian . On May 9, 11:53 am, "Jamey Cribbs" <jcri...-5tZyCCM3m2VWk0Htik3J/w@public.gmane.org> wrote:> try: > > Socket.gethostname > > You may need to require the socket library first. > > Jamey > > On Fri, May 9, 2008 at 12:41 PM, Nallamani <padmamadhu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > I have written an rake task where I need to access "Hostname" . I need > > this feature because I will be testing my application using the rake > > task both locally and on live server . > > > I found code in another language which does the same > > > hostname = os.environ.get(''HOSTNAME'') > > > puts "hostname =" + hostname > > > Is there anything similar to the above code in rails which I can use > > in my application . > > > Thanks, > >MadhuNallamani--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---