rakudo2 rakudo2 - 7 months ago 47
Ruby Question

ruby assign variable from system in apache server?

Im trying to test this command for export a system variable to ruby in my cgi server but not works

system({"MYVAR" => mk, "baz" => varpage2}, 'uuid=$(convert "$baz$MYVAR.png" -sample 100% -alpha remove -define connected-components:verbose=true -connected-components -4 -auto-level ccr3edsult.png ); export uuid')
File.open("uuid", "w") do |f| f.puts ENV["uuid"].inspect end

Please help me

Answer Source

Environment variables are not a good fit for this use case because the calling program can never see the environment of the called program.

You can use backticks to get the output of a program instead:

File.open("uuid", "w") do |f|
  f.puts `convert #{Shellwords.escape(varpage2 + mk + ".png")} -sample 100% -alpha remove -define connected-components:verbose=true -connected-components -4 -auto-level ccr3edsult.png`
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download