During development of an application, there will come cases when we need to access system command from our program itself. In some cases we just need to know if the status was complete, in some cases, we also need to know the output the application returns.But before we start, let’s find out what Shell Commands are. Simply put, the shell is a program that takes your commands from the keyboard and gives them to the operating system to perform. There are several additional shell programs available on a typical Linux system. Described below are 6 different way to execute a shell script from ruby and their properties.
Kernel#exec (or simply exec) replaces the current process by running the given command, which can take one of the following forms:
command line string which is passed to the standard shell
exec(cmdname, arg1, …)
command name and one or more arguments (no shell)
exec([cmdname, argv0], arg1, …)
command name, argv and zero or more arguments (no shell)
In the first form, the string is taken as a command line that is subject to shell expansion before being executed.
In the second form …