Sha256: b64af44e176a3082b8f5275551bab74f5f9eeb552f9212c621283850d05d1812

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

---
title: About the bash Resource
---

# bash

Use the `bash` InSpec audit resource to test an arbitrary command that is run on the system using a Bash script.

<br>

## Syntax

A `command` resource block declares a command to be run, one (or more) expected outputs, and the location to which that output is sent:

    describe bash('command') do
      it { should exist }
      its('property') { should eq 'expected value' }
    end

where

* `'command'` must specify a command to be run
* `'property'` is one of `exit_status`, `stderr`, or `stdout`
* `'expected value'` tests the output of the command run on the system versus the expected output stated in the test

For example:

    describe bash('ls -al /') do
      its('stdout') { should match /bin/ }
      its('stderr') { should eq '' }
      its('exit_status') { should eq 0 }
    end

<br>

## Supported Properties

* `exit_status`, `stderr`, `stdout`

<br>

## Property Examples

### exit_status

The `exit_status` property tests the exit status for the command:

    its('exit_status') { should eq 0 }

### stderr

The `stderr` property tests results of the command as returned in standard error (stderr):

    its('stderr') { should eq '' }

### stdout

The `stdout` property tests results of the command as returned in standard output (stdout).

    its('stdout') { should match /bin/ }

<br>

## Matchers

For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).

### exist

If an absolute path is provided, the `exist` matcher tests if the command exists on the filesystem at the specified location. Otherwise, the `exist` matcher tests if the command is found in the PATH.

    it { should exist }


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inspec-1.51.18 docs/resources/bash.md.erb
inspec-1.51.6 docs/resources/bash.md.erb