Replace complex subprocess calls in a Python script by importing and calling shell commands as regular Python functions.
Automate system administration tasks in Python by chaining CLI tools like git, rsync, and docker naturally.
Build a deployment script that runs multiple shell commands in sequence and captures their output as Python strings.
| amoffat/sh | sparckles/robyn | jrnl-org/jrnl | |
|---|---|---|---|
| Stars | 7,235 | 7,236 | 7,233 |
| Language | Python | Python | Python |
| Setup difficulty | easy | easy | easy |
| Complexity | 2/5 | 3/5 | 1/5 |
| Audience | developer | developer | writer |
Figures from each repo's GitHub metadata at analysis time.
Does not support Windows, requires a Unix-like operating system such as Linux or macOS.
sh is a Python library that lets you run any command-line program as if it were an ordinary Python function. Instead of writing subprocess calls with long argument lists, you import the program by name and call it directly. For example, to run ifconfig on the eth0 interface, you write from sh import ifconfig and then call ifconfig("eth0"). The output comes back as a string you can use in your Python code. The library is a replacement for Python's built-in subprocess module, which handles running external programs but requires more boilerplate to use. sh aims to make that same task feel natural and concise. It works on Linux, macOS, and other Unix-like operating systems, but it does not support Windows because it relies on Unix system calls internally. Compatible Python versions are 3.8 through 3.12 and also PyPy. Installing it takes one pip command. The full documentation with usage examples and advanced options is hosted at sh.readthedocs.io. The README itself is brief and mostly covers installation and how to run the test suite for developers who want to contribute. The project is actively maintained, currently at version 2, and there is a migration guide for users upgrading from the earlier 1.x version. Tests run inside Docker containers against all supported Python versions.
A Python library that turns any command-line program into a callable Python function, replacing verbose subprocess calls with simple, readable one-liners.
Mainly Python. The stack also includes Python, PyPy.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.