sshscript


Namesshscript JSON
Version 2.0.2 PyPI version JSON
download
home_pagehttps://github.com/iapyeh/sshscript
SummaryWrite Python scripts to automate SSH and subprocess operations.
upload_time2023-10-17 03:39:52
maintainer
docs_urlNone
authorHsin Yuan Yeh
requires_python>=3.8
licenseMIT
keywords pypi sshscript ssh paramiko subprocess shell script
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
                
SSHScript
#########
System automation is the process of repeating network and execution operations to achieve desired results. SSHScript is a Python library that makes it easy to create system automation processes. It provides a simple and intuitive interface for executing commands on local and remote hosts, without requiring any knowledge of the subprocess module or Paramiko (SSH).

SSHScript is technically an integration of the subprocess and Paramiko modules, but it presents an unified interface that is more convenient and expressive for system automation tasks. It is also pure Python, which means that SSHScript scripts can be easily integrated with other Python libraries and tools.

Here is an example of a simple script in SSHScript syntax(v2):

.. code-block:: python

    ## filename: example.spy
    ## run: sshscript example.spy
    $hostname
    ## get output by $.stdout, $.stderr and $.exitcode
    print('localhost name is ', $.stdout.strip())
    ## get an interactive sudo console of locahost
    with $.sudo('password') as sudoconsole:
        sudoconsole.exec_command('whoami')
        assert 'root' in sudoconsole.stdout
        sudoconsole.exec_command('ls -l $HOME')

    ## connect to remote by ssh
    with $.connect('user1@host', 'password):
        $hostname
        ## get output by $.stdout, $.stderr and $.exitcode
        print('remote name is ', $.stdout.strip())
        ## get an interactive sudo console of remote host
        with $.sudo('password') as sudoconsole:
            sudoconsole.exec_command('whoami')
            assert 'root' in sudoconsole.stdout
            sudoconsole.exec_command('ls -l $HOME')
        with $.connect('user2@nestedhost', pkey=$.pkey('/home/user1/.ssh/id_rsa')):
            $hostname
            ## get output by $.stdout, $.stderr and $.exitcode
            print('nested remote name is ', $.stdout.strip())
            ## get an interactive sudo console of remote host
            with $.sudo('password') as sudoconsole:
                sudoconsole.exec_command('whoami')
                assert 'root' in sudoconsole.stdout
                sudoconsole.exec_command('ls -l $HOME')


Here is an example of a simple script with SSHScript module(v2):

.. code-block:: python

    ## filename: example.py
    ## run: python3 example.py
    import sshscript
    from sshscript import SSHScriptSession
    session = SSHScriptSession()
    # Execute a command on the local host
    session.exec_command('df')
    for line in session.stdout.split('\n'):
        cols = line.split()
        if len(cols)>5: print(f'ussage of {cols[0]} is {cols[4]}')
    ## connect to remote by ssh
    with session.connect('user1@host', 'password) as remote_session:
        # Execute a command on the remote host
        remote_session.exec_command('df')
        for line in remote_session.stdout.split('\n'):
            cols = line.split()
            if len(cols)>5: print(f'ussage of {cols[0]} is {cols[4]}')
        with remote_session.connect('user2@nestedhost', pkey=remote_session.pkey('/home/user1/.ssh/id_rsa') as nested_remote_session:
            # Execute a command on the remote host
            nested_remote_session.exec_command('df')
            for line in nested_remote_session.stdout.split('\n'):
                cols = line.split()
                if len(cols)>5: print(f'ussage of {cols[0]} is {cols[4]}')


SSHScript can be used to automate a wide variety of system tasks, such as:

* Deploying and configuring servers
* Managing backups and restores
* Monitoring and troubleshooting systems
* Automating repetitive tasks

SSHScript is a powerful tool for system automation, and it is easy to use, even for those with limited programming experience.

Releases
========

The new experimental release is 2.0.2 (2023/10/6). There are lots of changes, but documentation is on working.

The last stable version is 1.1.17. (2022/9/22). Relase Notes_

More
====

* docs_

* Examples_


.. bottom of content

.. _paramiko : https://www.paramiko.org/

.. _docs : https://iapyeh.github.io/sshscript/index

.. _Examples : https://iapyeh.github.io/sshscript/examples/index


.. _Notes : https://iapyeh.github.io/sshscript/release-v1.1.17

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/iapyeh/sshscript",
    "name": "sshscript",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "pypi,sshscript,ssh,paramiko,subprocess,shell script",
    "author": "Hsin Yuan Yeh",
    "author_email": "iapyeh@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f8/7e/caf418927819d2906ba295cadb2f4248d40f300d26b06064ce1080d07e5a/sshscript-2.0.2.tar.gz",
    "platform": null,
    "description": "    \nSSHScript\n#########\nSystem automation is the process of repeating network and execution operations to achieve desired results. SSHScript is a Python library that makes it easy to create system automation processes. It provides a simple and intuitive interface for executing commands on local and remote hosts, without requiring any knowledge of the subprocess module or Paramiko (SSH).\n\nSSHScript is technically an integration of the subprocess and Paramiko modules, but it presents an unified interface that is more convenient and expressive for system automation tasks. It is also pure Python, which means that SSHScript scripts can be easily integrated with other Python libraries and tools.\n\nHere is an example of a simple script in SSHScript syntax(v2):\n\n.. code-block:: python\n\n    ## filename: example.spy\n    ## run: sshscript example.spy\n    $hostname\n    ## get output by $.stdout, $.stderr and $.exitcode\n    print('localhost name is ', $.stdout.strip())\n    ## get an interactive sudo console of locahost\n    with $.sudo('password') as sudoconsole:\n        sudoconsole.exec_command('whoami')\n        assert 'root' in sudoconsole.stdout\n        sudoconsole.exec_command('ls -l $HOME')\n\n    ## connect to remote by ssh\n    with $.connect('user1@host', 'password):\n        $hostname\n        ## get output by $.stdout, $.stderr and $.exitcode\n        print('remote name is ', $.stdout.strip())\n        ## get an interactive sudo console of remote host\n        with $.sudo('password') as sudoconsole:\n            sudoconsole.exec_command('whoami')\n            assert 'root' in sudoconsole.stdout\n            sudoconsole.exec_command('ls -l $HOME')\n        with $.connect('user2@nestedhost', pkey=$.pkey('/home/user1/.ssh/id_rsa')):\n            $hostname\n            ## get output by $.stdout, $.stderr and $.exitcode\n            print('nested remote name is ', $.stdout.strip())\n            ## get an interactive sudo console of remote host\n            with $.sudo('password') as sudoconsole:\n                sudoconsole.exec_command('whoami')\n                assert 'root' in sudoconsole.stdout\n                sudoconsole.exec_command('ls -l $HOME')\n\n\nHere is an example of a simple script with SSHScript module(v2):\n\n.. code-block:: python\n\n    ## filename: example.py\n    ## run: python3 example.py\n    import sshscript\n    from sshscript import SSHScriptSession\n    session = SSHScriptSession()\n    # Execute a command on the local host\n    session.exec_command('df')\n    for line in session.stdout.split('\\n'):\n        cols = line.split()\n        if len(cols)>5: print(f'ussage of {cols[0]} is {cols[4]}')\n    ## connect to remote by ssh\n    with session.connect('user1@host', 'password) as remote_session:\n        # Execute a command on the remote host\n        remote_session.exec_command('df')\n        for line in remote_session.stdout.split('\\n'):\n            cols = line.split()\n            if len(cols)>5: print(f'ussage of {cols[0]} is {cols[4]}')\n        with remote_session.connect('user2@nestedhost', pkey=remote_session.pkey('/home/user1/.ssh/id_rsa') as nested_remote_session:\n            # Execute a command on the remote host\n            nested_remote_session.exec_command('df')\n            for line in nested_remote_session.stdout.split('\\n'):\n                cols = line.split()\n                if len(cols)>5: print(f'ussage of {cols[0]} is {cols[4]}')\n\n\nSSHScript can be used to automate a wide variety of system tasks, such as:\n\n* Deploying and configuring servers\n* Managing backups and restores\n* Monitoring and troubleshooting systems\n* Automating repetitive tasks\n\nSSHScript is a powerful tool for system automation, and it is easy to use, even for those with limited programming experience.\n\nReleases\n========\n\nThe new experimental release is 2.0.2 (2023/10/6). There are lots of changes, but documentation is on working.\n\nThe last stable version is 1.1.17. (2022/9/22). Relase Notes_\n\nMore\n====\n\n* docs_\n\n* Examples_\n\n\n.. bottom of content\n\n.. _paramiko : https://www.paramiko.org/\n\n.. _docs : https://iapyeh.github.io/sshscript/index\n\n.. _Examples : https://iapyeh.github.io/sshscript/examples/index\n\n\n.. _Notes : https://iapyeh.github.io/sshscript/release-v1.1.17\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Write Python scripts to automate SSH and subprocess operations.",
    "version": "2.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/iapyeh/sshscript/issues",
        "Homepage": "https://github.com/iapyeh/sshscript"
    },
    "split_keywords": [
        "pypi",
        "sshscript",
        "ssh",
        "paramiko",
        "subprocess",
        "shell script"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f87ecaf418927819d2906ba295cadb2f4248d40f300d26b06064ce1080d07e5a",
                "md5": "1cdd7b35f6cb7543625e082fe83debf2",
                "sha256": "1f80afb554f8e1b95ebda93b3577d9d1f1fcb6311e37872c83185587fbeafb06"
            },
            "downloads": -1,
            "filename": "sshscript-2.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1cdd7b35f6cb7543625e082fe83debf2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 51024,
            "upload_time": "2023-10-17T03:39:52",
            "upload_time_iso_8601": "2023-10-17T03:39:52.990779Z",
            "url": "https://files.pythonhosted.org/packages/f8/7e/caf418927819d2906ba295cadb2f4248d40f300d26b06064ce1080d07e5a/sshscript-2.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-17 03:39:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "iapyeh",
    "github_project": "sshscript",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "sshscript"
}
        
Elapsed time: 0.13160s