An open API service indexing awesome lists of open source software.

https://github.com/maxg87/shell-interface

Helpful and convenient utilities to interact with UNIX shells
https://github.com/maxg87/shell-interface

python3 shell

Last synced: 2 months ago
JSON representation

Helpful and convenient utilities to interact with UNIX shells

Awesome Lists containing this project

README

          

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)

# Shell Interface

A lightweight Python library providing convenient utilities to interact with UNIX shells.

## Features

- Execute shell commands safely with error handling
- Pipe the output of one command to another
- Retrieve system user and group information
- Logging support with `loguru` (if installed)

## Usage

### Running Shell Commands

```python
from shell_interface import run_cmd

result = run_cmd(cmd=["ls", "-l"], capture_output=True)
print(result.stdout.decode())
```

### Piping Commands

```python
from shell_interface import pipe_pass_cmd_to_real_cmd

result = pipe_pass_cmd_to_real_cmd("echo Hello", ["grep", "Hello"])
print(result.stdout.decode())
```

### Getting User and Group Information

```python
from shell_interface import get_user, get_group

user = get_user()
group = get_group(user)
print(f"User: {user}, Group: {group}")
```