

This should not be used in normal Ruby app because it will exit the current Ruby process and run the command provided in exec function. Similar to system function, when calling the script using backtick, the Ruby app will also stop executing and wait for the result from the script 3. For example: `abcdad` # Exception here, Ruby app will crash with detailed error However, in case of exception, our program will also crash (the exception is passed onto the Ruby program). Unlike system function, we can get the output of the script using this character. Using backtickīacktick is the ` character (it is usually located under the Esc key in the keyboard). Notice that when executing the script using system function, the Ruby app will stop and wait for the command to be completed before continuing (synchronization mechanism) 2. For example: system("abcdad") # This will return nil Therefore, every error while executing the script will not be passed to our application. The output of system function will always be true or nil depending on whether or not the script has been executed without error. This function is a great way to run if you do not need to worry about the result returned by the script.

Ruby supports us running shell script in several ways 1.

What if our Ruby application needs the output from this do_something.py script? We have to find a way to call this script from Ruby app. From the extension, you can easily guess that it is written in Python. For example, imagine that I have a script do_something.py which performs a very complex calculation and returns the result. Many times when we are developing an application using Ruby, we want to run a shell script to do certain task.
