Newbie question on using system syntax versus backticks

I keep running into this, and change my approach if undesirable effects
are encountered. But what I’d like to systematically understand is the
difference between issuing a system command such as:

  system( "some_system_command" )

and simply doing it with backticks:

  `some_system_command`

What is the difference, and is there an approach that is preferable in
terms of “good Ruby programming”??

Subject: newbie question on using system syntax versus backticks
Date: gio 23 mag 13 11:22:47 +0900
Sorry for the delay!

Quoting Thomas L. ([email protected]):

I keep running into this, and change my approach if undesirable effects
are encountered. But what I’d like to systematically understand is the
difference between issuing a system command such as:

  system( "some_system_command" )

and simply doing it with backticks:

  `some_system_command`

There is one fundamental difference: backticks return the output of
the command, while system() lets the output be shown on screen (or
wherever your stdout/stderr point to) and returns true or false,
according to whether the command returned with a zero (success) or
non-zero (failure) status.

If you have

v1=date
v2=system(‘date’)

v1 will contain something like “gio 23 mag 2013, 07.23.01, CEST\n”,
while v2 will contain true. Apart from that, as far as I know the
command is executed in the same way.

Carlo