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
Command from usual user:
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
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) # ResponseParser(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
Aliases
Some methods have "human commands" and aliases:
- client.run_cmd("ls /home/bobby")
- client.list_dir("/home/bobby")
- client.ls("/home/bobby")
Changelog
1.1.3 (08.08.2020)
get_pid method added
1.1.2 (25.04.2020)
- send_cmd deprecated
- fix password prompt in stderr
1.1.1 (29.03.2020)
get_md5 method added
1.1.0 (19.03.2020)
ResponseParser extended with json()
1.0.9 (28.02.2020)
Log filehandler writes in utf8 from now
1.0.8 (06.02.2020)
get_file_permission extended:
- added faq
- added "human=False" param returns access rights in human readable form otherwise in in octal
- added alias "stat"
1.0.7 (30.01.2020)
- ResponseParser methods notation changed.
- stdout -> str
- stderr -> str
- exited -> int
- ok -> bool
- command -> str
1.0.6 (29.01.2020)
- kill_user_session method added
1.0.5 (26.01.2020)
- logging refactored to avoid multiple log entries
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
Built Distribution
File details
Details for the file plinux-1.1.3.tar.gz
.
File metadata
- Download URL: plinux-1.1.3.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7f15364e7ecea4cdd5b401c8e85a39f387fff450c281aa2db3ea9074df3eedf |
|
MD5 | 9304ec2e5770796919760d4f24a13d4c |
|
BLAKE2b-256 | 0a3d2f4ae388fb4dff797fc40709022498a0bd864af96765d20eb759378aeb5c |
File details
Details for the file plinux-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: plinux-1.1.3-py3-none-any.whl
- Upload date:
- Size: 20.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5744a06d3e6cc08436b81c9d4380004609117a874dece104fb1202ee62a3e345 |
|
MD5 | 16b5cc539e74ff440d7d534eb2da2ede |
|
BLAKE2b-256 | 8a07903aeebd1c01748794b0c994891f5c12c04fb53ba3fd813fba30ebf42be1 |