Class: Patriot::Command::ShCommand
- Includes:
- Util::System
- Defined in:
- lib/patriot/command/sh_command.rb
Overview
a command which executes shell scripts
Example pbc
sh {
name "test"
commands "echo '#{_date_}' > /tmp/test.out"
}
Constant Summary
Constants included from Util::System
Util::System::DEFAULT_MAX_ERROR_MSG_SIZE, Util::System::DEFAULT_PATRIOT_TMP_DIR, Util::System::MAX_ERROR_MSG_SIZE_KEY, Util::System::PATRIOT_TMP_DIR_KEY, Util::System::STDERR_SUFFIX, Util::System::STDOUT_SUFFIX
Constants included from Util::Config
Util::Config::ADMIN_USER_KEY, Util::Config::DEFAULT_CONFIG, Util::Config::DEFAULT_PLUGIN_DIR, Util::Config::INFO_SERVER_PORT_KEY, Util::Config::PASSWORD_KEY, Util::Config::PLUGIN_DIR_KEY, Util::Config::PLUGIN_INIT_SCRIPT, Util::Config::PLUGIN_KEY, Util::Config::PLUGIN_LIB_DIR, Util::Config::USERNAME_KEY, Util::Config::WORKER_HOST_KEY, Util::Config::WORKER_USER_KEY
Instance Attribute Summary collapse
-
#commands ⇒ Object
writeonly
- String, Array
-
commands to execute.
-
#name ⇒ Object
writeonly
- String
-
string to be a part of job id.
-
#name_suffix ⇒ Object
writeonly
- String
-
suffix string to be a part of job id.
Attributes inherited from Base
#config, #parser, #post_processors, #start_datetime, #target_datetime, #test_mode
Instance Method Summary collapse
Methods included from Util::System
#do_fork, #execute_command, #tmp_dir
Methods inherited from Base
#[], #_HH_, #_date_, #_hour_, #_month_, #add_post_processor, #add_subcommand, #build, #command_name, #configure_attr, #initialize, #param, #produce, #require, #skip, #start_date_time, #suspend, #to_job, #validate_command_attrs
Methods included from CommandMacro
#add_dsl_function, #command_attr, #command_attrs, #declare_command_name, #private_command_attr, #serde_attrs, #validate_attr, #validate_existence, #validation_logics, #volatile_attr, #volatile_attrs
Methods included from Util::Logger
Methods included from Util::Config
Methods included from Util::DateUtil
#date_add, #date_add_year, #date_format, #date_sub, #date_sub_year, #date_to_month, #days_of_month, #days_of_month_until, #days_of_week, #hours, #month_add, #month_sub, #to_date_obj, #to_end_of_last_month, #to_end_of_month, #to_month, #to_start_of_month
Methods included from Util::Param
Methods included from Parser
#batch_macro, #import_erb_config, #load_macro, #new_command, #parse
Constructor Details
This class inherits a constructor from Patriot::Command::Base
Instance Attribute Details
#commands=(value) ⇒ Object (writeonly)
- String, Array
-
commands to execute
18 19 20 |
# File 'lib/patriot/command/sh_command.rb', line 18 command_attr :commands do |cmd, a, v| cmd.commands = v.is_a?(Array)? v : [v] end |
#name=(value) ⇒ Object (writeonly)
- String
-
string to be a part of job id
27 |
# File 'lib/patriot/command/sh_command.rb', line 27 command_attr :name, :name_suffix |
#name_suffix=(value) ⇒ Object (writeonly)
- String
-
suffix string to be a part of job id
27 |
# File 'lib/patriot/command/sh_command.rb', line 27 command_attr :name, :name_suffix |
Instance Method Details
#configure ⇒ Object
36 37 38 39 |
# File 'lib/patriot/command/sh_command.rb', line 36 def configure @name_suffix ||= _date_ return self end |
#description ⇒ Object
42 43 44 |
# File 'lib/patriot/command/sh_command.rb', line 42 def description return @commands.join(@connector) end |
#execute ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/patriot/command/sh_command.rb', line 47 def execute @logger.info "start shell command " @commands.each do |c| execute_command(c) end @logger.info "end shell command " end |
#job_id ⇒ Object
31 32 33 |
# File 'lib/patriot/command/sh_command.rb', line 31 def job_id return "#{command_name}_#{@name}_#{@name_suffix}" end |