joemost45 joemost45 - 7 months ago 23
Ruby Question

Run command in cmd from Ruby

I know this is probably a really simple question, but I am having a really hard time finding a solution. I am working on windows in cmd. I am simply trying to use this command:
find /i \"chef_server_url\" C:/chef/client.rb

I know the command works.. it simply returns a url in a file that I wanted to check...

I want to execute this in code and return the results in my code.. but am having a hard time formatting the string especially with the escape characters

I am using %x[] to do so... so idealy I would just say %x[find /i \"chef_server_url\" C:/chef/client.rb]

But the c:/chef/client.rb will nto format correctly because it thinks /c and /c are not supposed to be that way


Are you trying to access the Chef Server URL from inside Chef? You can use Chef::Config[:chef_server_url] but the deeper question is what you trying to do?