The cross-platform tool to execute bash commands remotely.
Project description
Plinux
Cross-platform tool to work with remote Linux OS.
Plinux based on paramiko project. It can establish ssh connection to a remote server, execute command as user or with sudo rights. Plinux returns object with exit code, sent command, stdout/sdtderr response.
Installation
For most users, the recommended method to install is via pip:
pip install plinux
Import
from plinux import Plinux
Usage
The most recommended usage way:
from plinux import Plinux
client = Plinux(host="172.16.0.124", username="bobby", password="qawsedrf")
response = client.run_cmd("hostname")
print(response.stdout) # WebServer
print(response.ok) # True
from plinux import Plinux
client = Plinux()
response = client.run_cmd_local("hostname")
print(response.stdout) # WebServer
print(response.ok) # True
Command using sudo:
from plinux import Plinux
client = Plinux(host="172.16.0.124", username="bobby", password="qawsedrf", logger_enabled=True)
response = client.run_cmd("systemctl stop myservicename.service", sudo=True)
print(response) # SSHResponse(response=(0, None, None, "sudo -S -p '' -- sh -c 'systemctl stop myservicename.service'"))
print(response.command) # sudo -S -p '' -- sh -c 'systemctl stop myservicename.service'
print(response.exited) # 0
SFTP usage:
from plinux import Plinux
tool = Plinux(host="ftp.test.local", username="bobby", password="qawsedrf")
sftp = tool.sftp
print(sftp.listdir())
SQLite3 usage:
from plinux import Plinux
client = Plinux(host="cdn1.test.local", username="bobby", password="qawsedrf")
db_path = '/opt/ProductName/rxdb/StorageConfig.db'
sql = 'select Data from DtoDataContainer'
db = client.sqlite3(db_path, sql).json()
print(db) # {"Settings1": 1, "Settings2": 2...,"Settings10": 10}
print(db['Setting1']) # {"Settings1": 1}
Aliases
Some methods have "human commands" and aliases:
- client.run_cmd("cat /home/bobby/text")
- client.cat("/home/bobby/text")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
plinux-2.1.0.tar.gz
(22.7 kB
view details)
Built Distribution
plinux-2.1.0-py3-none-any.whl
(22.0 kB
view details)
File details
Details for the file plinux-2.1.0.tar.gz
.
File metadata
- Download URL: plinux-2.1.0.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbc25a0aa45575e78624ea3e3bc34083c44184d30f018e0370df3e2b5e6fef24 |
|
MD5 | 4c1400ce2f22abc985bb6c77e17b1b69 |
|
BLAKE2b-256 | 679f08492b106613cde2f6ddef23a2e3e02c15d67584f2fc9b90f6e88f8294c2 |
File details
Details for the file plinux-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: plinux-2.1.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ff8554d5bc1611c8505e0415f3b3abdc276fad7abacd942390a676b6ae735c6 |
|
MD5 | 9a5d017c0fc7b775414de702e9f81312 |
|
BLAKE2b-256 | 0cbdb6064d0f6826167a991910427119b09d575e974ce7c69d471cbbfe3d63a6 |