> For the complete documentation index, see [llms.txt](https://syslog-macos-testing.gitbook.io/syslog-macos-testing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://syslog-macos-testing.gitbook.io/syslog-macos-testing/modules/afprog-2/program-destination-driver.md).

# program() Destination Driver

The program() driver starts an external application or script and sends the log messages to its standard input (stdin).

### Important Information

Usually, every message is a single line (ending with a newline character), which your script can process. Make sure that your script runs in a loop and keeps reading the standard input — it should not exit. (If your script exits, syslog-ng OSE tries to restart it.)

### Status <a href="#status" id="status"></a>

| Architecture | Status |
| :----------: | :----: |
|      x86     |  Works |
|      ARM     |  Works |

### How to Test <a href="#how-to-test" id="how-to-test"></a>

To test the program() destination driver, we will make a shell script that receives input and stores it into a file or displays it on the console. Then, using the program destination driver, we will pass a custom message to this script and see the results in the file.&#x20;

> Note: The script is started by the driver, and in case of a exit, it is restarted automatically.

#### Shell Script <a href="#shell-script" id="shell-script"></a>

```
#!/bin/sh
while read line ; do
echo $line >> /Users/yash/Documents/test.txt
done
```

#### Configuration File Used <a href="#configuration-file-used" id="configuration-file-used"></a>

```
@version: 3.31
@include "scl.conf"

source custom
{
    example-msg-generator(
        num(20)
        freq(2)
        template("Random Message")
    );
};

destination d_prog { 
    program("/Users/yash/Documents/script"); 
};


log {
    source(custom);
    destination(d_prog);
};
```

#### Proof

![Testing program() destination on macOS (x86)](https://3267548193-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaZdBoDvCx_0JwOUICk%2F-McEP3xPF36ZzsdyN8Lc%2F-McEPMStRCgWB2V66k4a%2FScreenshot%202021-06-15%20at%202.23.06%20PM.png?alt=media\&token=674c1814-f7ba-417b-b832-e1dc90daa7b4)

![Testing program() destination on macOS (ARM)](https://3267548193-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MaZdBoDvCx_0JwOUICk%2F-MhXn5_Uy8Ayiemsnkwk%2F-MhXo5HnDTzS-bnE5lbf%2FScreen%20Shot%202021-08-20%20at%2012.06.18%20PM.png?alt=media\&token=5a15b1d4-fe93-4617-8913-65ad907e3b99)
