If you enclose a string in backquotes, or use the delimited form
prefixed by
%x
, it will (by default) be executed as a command by
your underlying operating system.
The value of the expression is the
standard output of that command. Newlines will not be stripped, so it is
likely that the value you get back will have a trailing return or
linefeed character.
`date`
|
� |
"Sun Jun 9 00:08:26 CDT 2002\n"
|
`dir`.split[34]
|
� |
"lib_singleton.tip"
|
%x{echo "Hello there"}
|
� |
"Hello there\n"
|
You can use expression expansion and all the usual escape sequences in
the command string.
for i in 0..3
status = `dbmanager status id=#{i}`
# ...
end
|
The exit status of the command is available in the global variable
$?
.