shell_exec

Crates.ioshell_exec
lib.rsshell_exec
version0.2.1
created_at2024-12-24 21:06:28.218215+00
updated_at2025-04-25 02:06:03.642879+00
descriptionCross platform library to execute shell scripts
homepage
repositoryhttps://github.com/caido/shell_exec
max_upload_size
id1494351
size20,246
Caido Bot (caidobot)

documentation

README

Shell Exec

github crates.io

Execute shell scripts asynchronously on multiple platforms. The goal of the library is to provide a simple interface to execute a user provided script on any shell. We try to avoid as much as possible writing temporary files.

use std::time::Duration;
use shell_exec::{Execution, Shell};

let execution = Execution::builder()
    .shell(Shell::Bash)
    .cmd(
        r#"
        INPUT=`cat -`;
        echo "hello $INPUT"
        "#
        .to_string(),
    )
    .timeout(Duration::from_millis(10000))
    .build();

let data = execution.execute(b"world").await.unwrap();

assert_eq!(b"hello world"[..], data);
Commit count: 13

cargo fmt