Class: Webgen::Tag::ExecuteCommand
- Inherits:
-
Object
- Object
- Webgen::Tag::ExecuteCommand
- Includes:
- Base
- Defined in:
- lib/webgen/tag/executecommand.rb
Overview
Executes the given command and returns the standard output. All special HTML characters are escaped.
Constant Summary collapse
- BIT_BUCKET =
(Config::CONFIG['host_os'] =~ /mswin|mingw/ ? "nul" : "/dev/null")
Instance Method Summary collapse
-
#call(tag, body, context) ⇒ Object
Execute the command and return the standard output.
Methods included from Base
#create_params_hash, #create_tag_params, #param, #set_params
Methods included from WebsiteAccess
Methods included from Loggable
Instance Method Details
#call(tag, body, context) ⇒ Object
Execute the command and return the standard output.
18 19 20 21 22 23 24 25 26 |
# File 'lib/webgen/tag/executecommand.rb', line 18 def call(tag, body, context) command = param('tag.executecommand.command') output = `#{command} 2> #{BIT_BUCKET}` if $?.exitstatus != 0 raise "Command '#{command}' in <#{context.ref_node.alcn}> has return value != 0: #{output}" end output = CGI::escapeHTML(output) if param('tag.executecommand.escape_html') [output, param('tag.executecommand.process_output')] end |