

If you do not want to hard-code the path to the ruby executable, you can use the env command in the shebang line to search for the ruby executable in your PATH and execute it. Once you have completed a script, it's common to create a ~/bin directory, add this to your PATH, and move your completed script here for running on a day-to-day basis. Running an executable Ruby script that is located in the current directory looks like this:
#How to write c code within ruby windows
Hence, you can still run the Ruby script on operating systems such as Windows whose shell does not support shebang lines. However the simple, elegant patterns of Ruby can be pretty unintuitive once translated into the language of the API. You can think of the C API is being a big, clunky alternative to writing normal Ruby code. The shebang line is ignored by Ruby – since the line begins with a hash, Ruby treats the line as a comment. The Ruby source uses some fairly sophisticated C, so you should at least feel comfortable reading it. More commonly, youd place your Ruby program in a file and.

The other common place to find the ruby executable is /usr/local/bin/ruby. The -e command-line option causes the interpreter to execute a single specified line of Ruby code.

If your ruby executable is not in the /usr/bin directory, change the shebang line to point to the correct path.
