Base on all my readings on the web the difference between backtick
and system
is what is returned . backtick
returns STDOUT while system
returns true
or false
.
And I was told that both of them use subshell to perform the operation.
However I am noticing another difference.
output = system('aaa')
puts "output is: #{output}"
output = `aaa`
puts "output is: #{output}"
Result of above code is
$ ruby test.rb
output is:
lab.rb:4:in ``': No such file or directory - aaa (Errno::ENOENT) from test.rb:4:in `<main>'
So it seems in the case of backtick
the exceptions are raised to the main program. Operation system
swallows the exception and the main program never sees the exception.
I'm using ruby 1.9.3 .
Is my analysis right ?
UPDATE: Got the answer. It's here https://gist.github.com/3730986 .
System is a pure ruby interface to gather systems information from the current host. System offers a simple to use interface to gather an array of information including; OS, CPU, Filesystem etc...
Ruby command is a free and open source programming language; it is flexible and is feature rich. As the name suggests, ruby indeed is a jewel language which comes at a very low entry cost. Its plug and play capability and also easily readable syntax makes it very user-friendly.
Copying the answer from the edited question body in order to remove this question from the "Unanswered" filter:
Got the answer. It's here https://gist.github.com/3730986 .
~ answer per nodejs99
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With