Hello,
is there a possibility in ruby to execute a system command by variable?
this code don’t work…
cmd=’/bin/ls’
output=%(cmd)
gp-
Hello,
is there a possibility in ruby to execute a system command by variable?
this code don’t work…
cmd=’/bin/ls’
output=%(cmd)
gp-
cmd='/bin/ls'
output=%(cmd)
Try
output = `#{cmd}`
Guy Decoux
Hi,
You can use the ` (backquote), and it is similar as replacing the value of
a variable in a string:
cmd = '/bin/ls'
output = `#{cmd}`
puts output
Regards,
Bill
==========================================================================
Gian Paolo Marra gpmarra@le.isiata.le.cnr.it wrote:
Hello,
is there a possibility in ruby to execute a system command by variable?
this code don’t work…
cmd=‘/bin/ls’
output=%(cmd)
gp-
Hi Bill!
Thank you!!
Best regards,
gp-
William Djaja Tjokroaminata wrote:
Hi,
You can use the ` (backquote), and it is similar as replacing the value of
a variable in a string:cmd = '/bin/ls' output = `#{cmd}` puts output
Regards,
Bill
Gian Paolo Marra gpmarra@le.isiata.le.cnr.it wrote:
Hello,
is there a possibility in ruby to execute a system command by variable?
this code don’t work…
cmd=‘/bin/ls’
output=%(cmd)gp-