user1787282 user1787282 - 2 years ago 97
Ruby Question

Add variable in %x command in ruby

I am trying to use the %x ( ) and use a variable that i've used earlier to determine a path of a file that i want to run.

essentially i want to do something like this

location = "/home/myhome/somefolder"
%x ("ls " + location)

Is there a way to do this?

Answer Source

Your code works

%x ("ls " + location)


%x ("ls #{location}")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download