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: 3 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 (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-27T07:12:12.000Z (almost 2 years ago)
- Last Synced: 2025-03-26T01:41:31.476Z (3 months ago)
- Topics: c, c-lib, c-library, script
- Language: C
- Size: 44.9 KB
- Stars: 4
- Watchers: 3
- 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
[](https://github.com/sagiegurari/c_scriptexec/actions)
[](https://github.com/sagiegurari/c_scriptexec/releases)
[](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.