From: Francesco Vollero Date: 2010-05-30T20:31:38+09:00 Subject: Re: Another complete beginners question Il 30/05/10 13.20, Josh Cheek ha scritto: > On Sat, May 29, 2010 at 2:43 PM, Emma Pidrewrote: > > >> Hi, i am in Osx and i had installed Ruby 1.8.7. I want to make a >> tutorial, i am a beginner in ruby. My problem is that when i want to >> execute a program on ruby, example: code.rb, with "ruby code.rb" on >> Terminal, like all tutorials sais, a error come back: "-bash: code.rb: >> command not found" >> >> Well, there is a part that i am missing. Please help me. >> -- >> Posted via http://www.ruby-forum.com/. >> >> >> > Expounding on Francesco's answer: > > # add a shebang to the top of a file called hello_world.rb > # this directs the system(?) to use Ruby to interpret the file > $ echo '#!/usr/bin/env ruby'> hello_world.rb > > # append a statement that will output "hello world" to hello_world.rb > $ echo 'puts "hello world"'>> hello_world.rb > > # set permissions of hello_world.rb so that you can execute it > $ chmod 755 hello_world.rb > > # execute hello_world.rb and see that it outputs "hello world" > # the ./ in front is important, it says the file is located in the current > directory > $ ./hello_world.rb > hello world > > You're right, maybe my answer can get someone confused, to be 100% sure, Josh, let me write a ruby script :) ruby_sample.rb: -- #!/usr/bin/env ruby puts "hello world" -- and after you've to do what Josh say i mean, 3rd and 4th step. -Francesco