Execute commandline commands from inside ERB

(Sameer Varshney) #1

There are various command line executions available e.g. ‘oneuser show’ or ‘onevm list’ etc.
I can run these on command line with successful results.

I can successfully run these in an independent ruby program as below:
cmd = "onevm list"
output=%x[ #{cmd}]
print (output).to_json

But, if I put this code in OpenNebula’s custom route based .erb file, it fails and does not show any result. However if I change the command from ‘onevm list’ to ‘onevm’, I do get the output.

Although if I try replacing the command to ‘ls -l’, I do get the output.

So for some reason, the command as ‘onevm list’ or ‘oneuser show’ does not work. Please help, why these does not work (when used with second option separated by space).

Actually I’m try to call ‘oneuser create username password’ to create a new user from my customized registration page.