All Projects → sagiegurari → Run_script

sagiegurari / Run_script

Licence: apache-2.0
Run shell scripts in rust.

Programming Languages

rust
11053 projects
scripting
82 projects

Projects that are alternatives of or similar to Run script

Work Dummy
Ever needed to faff or pretend to be seriously at work? This repository hosts a powershell script that'd make anyone think you definitely bursting your ass solving problems.
Stars: ✭ 26 (-38.1%)
Mutual labels:  bash-script
Cfhookbash
Cloudflare hook bash for dehydrated - DNS-01 Challenge Let's Encrypt
Stars: ✭ 28 (-33.33%)
Mutual labels:  bash-script
Finalfusion Rust
finalfusion embeddings in Rust
Stars: ✭ 35 (-16.67%)
Mutual labels:  rust-library
Ubuntu Setup
script to configure fresh ubuntu install, or to update existing install
Stars: ✭ 8 (-80.95%)
Mutual labels:  bash-script
Simulacrum
A small library for creating mock objects in Rust.
Stars: ✭ 21 (-50%)
Mutual labels:  rust-library
Simple Sh Datascience
A collection of Bash scripts and Dockerfiles to install data science Tool, Lib and application
Stars: ✭ 32 (-23.81%)
Mutual labels:  bash-script
Wsl Docker Git Setup
Shell script to configure Windows Subsystem for Linux (WSL) & Ubuntu on Windows to use docker and docker-compose as well as a git-enabled prompt
Stars: ✭ 23 (-45.24%)
Mutual labels:  bash-script
Padd
PADD (formerly Chronometer2) is a more expansive version of the original chronometer.sh that is included with Pi-Hole. PADD provides in-depth information about your Pi-hole.
Stars: ✭ 1,011 (+2307.14%)
Mutual labels:  bash-script
Bashmultitool
A library for bash shell program containing useful functions. Can be imported into scripts to create colourful and functional scripts and TUIs.
Stars: ✭ 27 (-35.71%)
Mutual labels:  bash-script
Search Docker Registry V2 Script.1.0
view-private-registry is a simple bash script for listing images in a private registry v2, docker search registry-v2
Stars: ✭ 34 (-19.05%)
Mutual labels:  bash-script
Macos Virtualbox
Push-button installer of macOS Catalina, Mojave, and High Sierra guests in Virtualbox for Windows, Linux, and macOS
Stars: ✭ 11,634 (+27600%)
Mutual labels:  bash-script
Rust Csv
A CSV parser for Rust, with Serde support.
Stars: ✭ 911 (+2069.05%)
Mutual labels:  rust-library
Photon
⚡ Rust/WebAssembly image processing library
Stars: ✭ 963 (+2192.86%)
Mutual labels:  rust-library
Add Copyright
This is a Script to Automate adding the Copyright text to one or more source files Recursively.
Stars: ✭ 27 (-35.71%)
Mutual labels:  bash-script
Reqray
Log call tree summaries after each request for rust programs instrumented with `tracing`.
Stars: ✭ 37 (-11.9%)
Mutual labels:  rust-library
Craft Do Forge Recipe
Digital Ocean / Forge Recipe for CraftCMS websites
Stars: ✭ 24 (-42.86%)
Mutual labels:  bash-script
Jsonpath Rs
JSONPath for Rust
Stars: ✭ 31 (-26.19%)
Mutual labels:  rust-library
Log
Logging implementation for Rust
Stars: ✭ 1,012 (+2309.52%)
Mutual labels:  rust-library
House
Proof of Concept and Research repository.
Stars: ✭ 37 (-11.9%)
Mutual labels:  bash-script
Arccstr
Thread-safe, reference-counted null-terminated immutable Rust strings.
Stars: ✭ 34 (-19.05%)
Mutual labels:  rust-library

run_script

crates.io CI codecov
license Libraries.io for GitHub Documentation downloads
Built with cargo-make

Run shell scripts in rust.

Overview

This library enables to invoke shell scripts based on their content.
While std::process::Command works great to execute standalone command, you need more manual code to take a script text and execute it.
For this purpose, this library was created.

Usage

Simply include the library and invoke the run/spawn function with the script text and run options:

use run_script::ScriptOptions;

fn main() {
    let options = ScriptOptions::new();

    let args = vec![];

    // run the script and get the script execution output
    let (code, output, error) = run_script::run(
        r#"
         echo "Directory Info:"
         dir
         "#,
        &args,
        &options,
    )
    .unwrap();

    println!("Exit Code: {}", code);
    println!("Output: {}", output);
    println!("Error: {}", error);

    // run the script and get a handle to the running child process
    let child = run_script::spawn(
        r#"
         echo "Directory Info:"
         dir
         "#,
        &args,
        &options,
    )
    .unwrap();

    let spawn_output = child.wait_with_output().unwrap();

    println!("Success: {}", &spawn_output.status.success());
}

The library also provides the run_script!, spawn_script! and run_script_or_exit! macros for simpler usage.

use run_script::ScriptOptions;

fn main() {
    // simple call to run script with only the script text
    let (code, output, error) = run_script::run_script!(
        r#"
         echo "Test"
         exit 0
         "#
    )
    .unwrap();

    println!("Exit Code: {}", code);
    println!("Output: {}", output);
    println!("Error: {}", error);

    // run script invoked with the script text and options
    let options = ScriptOptions::new();
    let (code, output, error) = run_script::run_script!(
        r#"
         echo "Test"
         exit 0
         "#,
        &options
    )
    .unwrap();

    println!("Exit Code: {}", code);
    println!("Output: {}", output);
    println!("Error: {}", error);

    // run script invoked with all arguments
    let options = ScriptOptions::new();
    let (code, output, error) = run_script::run_script!(
        r#"
         echo "Test"
         exit 0
         "#,
        &vec!["ARG1".to_string(), "ARG2".to_string()],
        &options
    )
    .unwrap();

    println!("Exit Code: {}", code);
    println!("Output: {}", output);
    println!("Error: {}", error);

    // spawn_script! works the same as run_script! but returns the child process handle
    let child = run_script::spawn_script!(
        r#"
         echo "Test"
         exit 0
         "#
    )
    .unwrap();

    println!("PID: {}", child.id());
}

Installation

In order to use this library, just add it as a dependency:

[dependencies]
run_script = "^0.7.0"

API Documentation

See full docs at: API Docs

Contributing

See contributing guide

Release History

See Changelog

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].