I am trying to execute custom python script from Rails controller.
Assume I have this code:
command_string = "add_domain --domain=#{@domain.domain}"
command = `#{command_string}`
where add_domain is a custom python script (stored in /usr/bin with chmod +x permissions) that does some magic and returns following line:
Generation is completed.
I then log the output to text file for further debugging, but all it does, is returning the empty output, althrough if I attempt to execute it manually by executing same command in shell console, it works out just fine and returns the output above. It even runs perfectly fine from Rails console.
I am also certain that @domain.domain contains correct value, infact, issue still happens if I substitute it with static value, still, only empty value is returned and script is not executed properly.
The simple echo command on the other hand executes perfectly well and returns the value.
EDIT:
stdin, stdout, stderr = Open3.popen3(command_string)
stdout.gets
returns empty value too.
EDIT 2
It seems that it has something to do with environment, because backtick method works on local machine just fine.
EDIT 3
I also tried system method and %x(command_string) all returns empty output, which leads me to believe, there is something to do with server environment, althrough I repeat, if I run this command manually, works just fine.
Any help on where to dig is much appreciated.