Class | Webgen::Tag::ExecuteCommand |
In: |
lib/webgen/tag/executecommand.rb
|
Parent: | Object |
Executes the given command and returns the standard output. All special HTML characters are escaped.
BIT_BUCKET | = | (Config::CONFIG['host_os'] =~ /mswin|mingw/ ? "nul" : "/dev/null") |
Execute the command and return the standard output.
# File lib/webgen/tag/executecommand.rb, line 18 18: def call(tag, body, context) 19: command = param('tag.executecommand.command') 20: output = `#{command} 2> #{BIT_BUCKET}` 21: if $?.exitstatus != 0 22: raise Webgen::RenderError.new("Command '#{command}' has return value != 0: #{output}", 23: self.class.name, context.dest_node, context.ref_node) 24: end 25: output = CGI::escapeHTML(output) if param('tag.executecommand.escape_html') 26: [output, param('tag.executecommand.process_output')] 27: end