Skip to main content

The cross-platform tool to execute bash commands remotely.

Project description

PyPI version Python application

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


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.2.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

plinux-2.1.2-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file plinux-2.1.2.tar.gz.

File metadata

  • Download URL: plinux-2.1.2.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for plinux-2.1.2.tar.gz
Algorithm Hash digest
SHA256 90ccfa4529fe028ea6eef367876cd3e8372797550031f9ae67537d02973c4e73
MD5 66e3feeb07f9e974f51564731831c11d
BLAKE2b-256 fd55fbaf3177507eb9f608664570c9f0b8361b4d41a9bb6a7325ee8ed5e07095

See more details on using hashes here.

File details

Details for the file plinux-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: plinux-2.1.2-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.0

File hashes

Hashes for plinux-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9ad81079eb30c0a5d52d14f0278373b227eef2d34da527ea79b6cc27d0c4585a
MD5 f7a5558baa253a101c4f1bebee5ecae0
BLAKE2b-256 7018c440d182153b0497577c3e40a3b185f655fd23daa8cd196b19bff19f0958

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page