Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sagiegurari/c_scriptexec
Invoke complex multi command scripts with a single C api call.
https://github.com/sagiegurari/c_scriptexec
c c-lib c-library script
Last synced: 4 months ago
JSON representation
Invoke complex multi command scripts with a single C api call.
- Host: GitHub
- URL: https://github.com/sagiegurari/c_scriptexec
- Owner: sagiegurari
- License: apache-2.0
- Created: 2020-05-30T21:59:48.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-27T07:12:12.000Z (over 1 year ago)
- Last Synced: 2024-06-19T00:45:26.532Z (8 months ago)
- Topics: c, c-lib, c-library, script
- Language: C
- Size: 44.9 KB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# scriptexec
[![CI](https://github.com/sagiegurari/c_scriptexec/workflows/CI/badge.svg?branch=master)](https://github.com/sagiegurari/c_scriptexec/actions)
[![Release](https://img.shields.io/github/v/release/sagiegurari/c_scriptexec)](https://github.com/sagiegurari/c_scriptexec/releases)
[![license](https://img.shields.io/github/license/sagiegurari/c_scriptexec)](https://github.com/sagiegurari/c_scriptexec/blob/master/LICENSE)> Invoke complex multi command scripts with a single C api call.
* [Overview](#overview)
* [Usage](#usage)
* [Contributing](.github/CONTRIBUTING.md)
* [Release History](CHANGELOG.md)
* [License](#license)
## Overview
This library enables to invoke complex multi command scripts with a single C api call and get the script status code and out/err.```c
#include "scriptexec.h"
#include
#includeint main()
{
// invoke the script with default options
struct ScriptExecResult result = scriptexec_run("echo 1\necho 2\necho 3\necho 4");printf("Code: %d\nOutput:\n%s\nError:\n%s\n", result.code, result.out, result.err);
// invoke the script with custom options
struct ScriptExecOptions options = scriptexec_create_options();
options.runner = "bash"; // default is 'sh'
options.working_directory = "./target"; // default to current working directory
options.exit_on_error = true; // default true, will break script execution on any error
options.print_commands = true; // default false, if true will print every command before invocationresult = scriptexec_run_with_options("echo 1\necho 2\necho 3\necho 4", options);
printf("Code: %d\nOutput:\n%s\nError:\n%s\n", result.code, result.out, result.err);free(result.out);
free(result.err);
}
```## Contributing
See [contributing guide](.github/CONTRIBUTING.md)See [Changelog](CHANGELOG.md)
## License
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.