Module | Chef::Mixin::Command
In: | lib/chef/mixin/command/unix.rb lib/chef/mixin/command/windows.rb lib/chef/mixin/command.rb

### Methods

chdir_or_tmpdir handle_command_failures not_if only_if output_of_command run_command run_command_with_systems_locale

### Included Modules

::Chef::Mixin::Command::Windows ::Chef::Mixin::Command::Unix

### Classes and Modules

Module Chef::Mixin::Command::Unix
Module Chef::Mixin::Command::Windows

### Public Instance methods

chdir_or_tmpdir(dir, &block)

module_function :popen4

handle_command_failures(status, command_output, opts={})
not_if(command, args = {})

If command is a block, returns false if the block returns true, true if it returns false. ("Do not run this resource if the block is true")

If the command is not a block, executes the command. If it returns a 0 exitstatus, returns false. ("Do not run this resource if the command returns 0")

### Parameters

command<Block>, <String>: | A block to check, or a string to execute

### Returns

true: | Returns true if the block is false, or if the command returns a non-zero exit status.
false: | Returns false if the block is true, or if the command returns a 0 exit status.

only_if(command, args = {})

If command is a block, returns true if the block returns true, false if it returns false. ("Only run this resource if the block is true")

If the command is not a block, executes the command. If it returns any status other than 0, it returns false (clearly, a 0 status code is true)

### Parameters

command<Block>, <String>: | A block to check, or a string to execute

### Returns

true: | Returns true if the block is true, or if the command returns 0
false: | Returns false if the block is false, or if the command returns a non-zero exit code.

output_of_command(command, args)
run_command(args={})

### Parameters

args<Hash>: A number of required and optional arguments

      command<String>, <Array>: A complete command with options to execute or a command and options as an Array
      creates<String>: The absolute path to a file that prevents the command from running if it exists
      cwd<String>: Working directory to execute command in, defaults to Dir.tmpdir
      timeout<String>: How many seconds to wait for the command to execute before timing out
      returns<String>: The single exit value command is expected to return, otherwise causes an exception
      ignore_failure<Boolean>: Whether to raise an exception on failure, or just return the status
      output_on_failure<Boolean>: Return output in raised exception regardless of Log.level

      user<String>: The UID or user name of the user to execute the command as
      group<String>: The GID or group name of the group to execute the command as
      environment<Hash>: Pairs of environment variable names and their values to set before execution

### Returns

Returns the exit status of args[:command]

run_command_with_systems_locale(args={})

Call run_command but set LC_ALL to the system‘s current environment so it doesn‘t get changed to C.

### Parameters

args<Hash>: A number of required and optional arguments that will be handed out to run_command

### Returns

Returns the result of run_command

[Validate]