Classes to run shell commands trow linux pipe

dev-master 2023-06-05 20:26 UTC

This package is auto-updated.

Last update: 2024-05-01 00:07:37 UTC


README

It's small and lightweight pack to run shell script throw command pipe (bus). So useful to build webhooks on top of docker-container with shell scripts and link them with REST Api.

You no longer need to learn fancy package configurations for webhooks. Use the usual tools.

Installation

It's recommended that you use Composer to install shorts.

$ composer require loandbeholdru/pipe

Usage

Create pipe on host with php and give rights to read it on host with executing scripts (docker-composer example):

mkfifo /tmp/pipefile

On host/container with shell-scripts run main execution script:

./serve.sh [path_to_pipe] [path_to_reaction_dir]

Create command:

$command = new pipecommand("/tmp/pipefile", "/some/path/script_with_two_params.sh %s %s", $par1, $par2);

Create result trap:

$result = new piperesult("/tmp/pipefile", new brokenPipeException("When pipe not working!"));

Execute your command and get $strings from your shell-script:

$strings = pipe::exec($command, $result, new bashCommandErrorException("When your script return error!"));

Contributions

... are always welcome. Many times it is useful to just point out a use case the author have not thought about or come across.