R
robertlaferla
I am trying to construct a command line to be executed using backquote `` notation. i.e. capturing the output to a string
e.g.
#!/usr/bin/ruby -w
file = "/etc/motd"
string = `"cat " + file`
puts string
% ruby test.rb
sh: line 1: cat : command not found
This doesn't work. It appears that everything between the backquotes is treated as a quoted string. i.e. no variable substitution takes place.
How can I work around this?
e.g.
#!/usr/bin/ruby -w
file = "/etc/motd"
string = `"cat " + file`
puts string
% ruby test.rb
sh: line 1: cat : command not found
This doesn't work. It appears that everything between the backquotes is treated as a quoted string. i.e. no variable substitution takes place.
How can I work around this?