Skip to main content

The cross-platform tool to execute bash commands remotely.

Project description

PyPI version Build Status

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.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plinux-1.0.7.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distribution

plinux-1.0.7-py3-none-any.whl (19.7 kB view hashes)

Uploaded Python 3

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