#SSH #remote #experimentation #spur-py

spurs

Utilities for setting up and running experiments remotely

17 unstable releases

0.9.1 Sep 11, 2020
0.9.0 Jun 21, 2020
0.8.2 Jan 21, 2020
0.8.1 Nov 13, 2019
0.1.3 Nov 5, 2018

#76 in Science

Download history 32/week @ 2020-05-28 31/week @ 2020-06-04 1/week @ 2020-06-11 20/week @ 2020-06-18 3/week @ 2020-06-25 34/week @ 2020-07-02 1/week @ 2020-07-09 34/week @ 2020-07-16 20/week @ 2020-07-23 18/week @ 2020-07-30 19/week @ 2020-08-06 35/week @ 2020-08-13 21/week @ 2020-08-20 20/week @ 2020-08-27 51/week @ 2020-09-03 33/week @ 2020-09-10

93 downloads per month
Used in spurs-util

MIT/Apache

24KB
512 lines

spurs and spurs-util

Build

spurs: Latest version Documentation

spurs-util: Latest version Documentation

Utilities for setting up and running experiments remotely.

spurs is heavily inspired by spur.py but it also contains a bunch of utility routines that I have found useful. I will periodically add more as I find useful ones or people submit PRs.

Features

This repo contains two crates:

  1. spurs: A straight-forward, well-typed, idiomatic interface for running commands remotely via SSH, similar to spur.py.

  2. spurs-util: Utilities for common Linux admin operations, such as adding a user to a group or turning on a swap device or installing a package. This is by no means a complete set of such functions. So far it just includes the ones I have run into. Feel free to make PRs adding more.

Disclaimer

While I do intend to follow semver for the API, I don't not make guarantees about the format of output to stdout or stderr. It is not intended that one should try to parse the stdout/stderr output generated by spurs.

Example

use spurs::{cmd, ssh::{SshShell, Execute}};

const FOO: &str = "foo";
const HOST: &str = "1.2.3.4:22";
const USER: &str = "user";

// Create an SSH connection with host.
// (host doesn't have to be a `&str`; it can be any `ToSocketAddrs` type)
let shell = SshShell::with_default_key(USER, HOST)?;

// Run some commands on HOST as USER.

// ps -e | grep foo
shell.run(cmd!("ps -e | grep {}", FOO).use_bash())?;

// cd /home/user ; ls -a | grep user
shell.run(cmd!("ls -a | grep user").cwd("/home/user/").use_bash())?;

// sudo yum install -y qemu-kvm
shell.run(spurs::centos::yum_install(&["qemu-kvm"]))?;

It's also possible to

  • run commands in another thread and later wait for that thread
  • capture the stdout and stderr
  • allow a command to fail

For more information please see the spurs docs or the spurs-util docs. Feel free to open an issue on the repo if anything is unclear.

Usage

Add the crate spurs to your Cargo.toml dependencies.

Requires stable Rust 1.32 or newer.

License

Licensed under either of

at your option.

Dependencies

~7MB
~158K SLoC