def execute_script(code)
path = File.expand_path("xmpfilter.tmpfile_#{Process.pid}.rb", Dir.tmpdir)
File.open(path, "w"){|f| f.puts code}
at_exit { File.unlink path if File.exist? path}
stdout_path, stderr_path = (1..2).map do |i|
fname = "xmpfilter.tmpfile_#{Process.pid}-#{i}.rb"
File.expand_path(fname, Dir.tmpdir)
end
args = *(interpreter_command << %["#{path}"] << "2>" <<
%["#{stderr_path}"] << ">" << %["#{stdout_path}"])
system(args.join(" "))
[stdout_path, stderr_path].map do |fullname|
f = File.open(fullname, "r")
at_exit {
f.close unless f.closed?
File.unlink fullname if File.exist? fullname
}
f
end
end