{ "info": { "author": "Fotis Gimian", "author_email": "fgimiansoftware@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "Paramiko Expect\n===============\n\n.. image:: https://img.shields.io/pypi/l/paramiko-expect.svg\n :target: https://github.com/fgimian/paramiko-expect/blob/master/LICENSE\n\n.. image:: https://coveralls.io/repos/github/fgimian/paramiko-expect/badge.svg?branch=master\n :target: https://coveralls.io/github/fgimian/paramiko-expect?branch=master\n\n.. image:: https://img.shields.io/travis/fgimian/paramiko-expect.svg \n :target: https://travis-ci.org/fruch/paramiko-expect/\n\n.. image:: https://img.shields.io/pypi/v/paramiko-expect.svg \n :target: https://pypi.python.org/pypi/paramiko-expect/\n\n.. image:: https://img.shields.io/pypi/pyversions/paramiko-expect.svg \n :target: https://pypi.python.org/pypi/paramiko-expect/\n\n\n.. image:: https://raw.githubusercontent.com/fgimian/paramiko-expect/master/images/paramiko-expect-logo.png\n :alt: Paramiko Expect Logo\n\nArtwork courtesy of `Open Clip Art\nLibrary `_\n\nIntroduction\n------------\n\nParamiko Expect provides an expect-like extension for the Paramiko SSH library\nwhich allows scripts to fully interact with hosts via a true SSH\nconnection.\n\nThe class is constructed with an SSH Client object (this will likely be\nextended to support a transport in future for more flexibility).\n\nQuick Start\n-----------\n\nTo install paramiko-expect, simply run the following at your prompt:\n\n.. code:: bash\n\n # from pypi\n pip insall paramiko-expect\n\n # from source\n pip install git+https://github.com/fgimian/paramiko-expect.git\n\nSo let's check out how it works in general (please see\n`paramiko_expect-demo.py `_\nfor the complete code):\n\n.. code:: python\n\n # Connect to the host\n client.connect(hostname=hostname, username=username, password=password)\n\n # Create a client interaction class which will interact with the host\n interact = SSHClientInteraction(client, timeout=10, display=True)\n interact.expect(prompt)\n\n # Run the first command and capture the cleaned output, if you want the output\n # without cleaning, simply grab current_output instead.\n interact.send('uname -a')\n interact.expect(prompt)\n cmd_output_uname = interact.current_output_clean\n\n # Now let's do the same for the ls command but also set a timeout for this\n # specific expect (overriding the default timeout)\n interact.send('ls -l /')\n interact.expect(prompt, timeout=5)\n cmd_output_ls = interact.current_output_clean\n\n # To expect multiple expressions, just use a list. You can also selectively\n # take action based on what was matched.\n\n # Method 1: You may use the last_match property to find out what was matched\n interact.send('~/paramiko_expect-demo-helper.py')\n interact.expect([prompt, 'Please enter your name: '])\n if interact.last_match == 'Please enter your name: ':\n interact.send('Fotis Gimian')\n interact.expect(prompt)\n\n # Method 2: You may use the matched index to determine the last match (like pexpect)\n interact.send('~/paramiko_expect-demo-helper.py')\n found_index = interact.expect([prompt, 'Please enter your name: '])\n if found_index == 1:\n interact.send('Fotis Gimian')\n interact.expect(prompt)\n\n # Send the exit command and expect EOF (a closed session)\n interact.send('exit')\n interact.expect()\n\n # Print the output of each command\n print '-'*79\n print 'Cleaned Command Output'\n print '-'*79\n print 'uname -a output:'\n print cmd_output_uname\n print 'ls -l / output:'\n print cmd_output_ls\n\n**Important**: Before running this script, be sure to place\n`paramiko_expect-demo-helper.py `_\nin ``~``.\n\nThe print statements at the bottom of the script provide the following\noutput:\n\n.. code:: bash\n\n -------------------------------------------------------------------------------\n Cleaned Command Output\n -------------------------------------------------------------------------------\n uname -a output:\n Linux fotsies-ubuntu-testlab 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux\n\n ls -l / output:\n total 77\n drwxr-xr-x 2 root root 4096 May 1 22:21 bin\n drwxr-xr-x 4 root root 1024 May 1 22:22 boot\n drwxr-xr-x 15 root root 4300 Jun 12 15:00 dev\n drwxr-xr-x 90 root root 4096 Jun 12 16:45 etc\n drwxr-xr-x 4 root root 4096 May 1 23:37 home\n lrwxrwxrwx 1 root root 33 May 1 22:18 initrd.img -> /boot/initrd.img-3.2.0-23-generic\n drwxr-xr-x 18 root root 4096 May 1 22:21 lib\n drwxr-xr-x 2 root root 4096 May 1 22:17 lib64\n drwx------ 2 root root 16384 May 1 22:17 lost+found\n drwxr-xr-x 4 root root 4096 May 1 22:18 media\n drwxr-xr-x 2 root root 4096 Apr 19 19:32 mnt\n drwxr-xr-x 2 root root 4096 May 1 22:17 opt\n dr-xr-xr-x 84 root root 0 Jun 12 15:00 proc\n drwx------ 3 root root 4096 May 30 23:32 root\n drwxr-xr-x 15 root root 560 Jun 12 17:02 run\n drwxr-xr-x 2 root root 4096 Jun 4 20:59 sbin\n drwxr-xr-x 2 root root 4096 Mar 6 04:54 selinux\n drwxr-xr-x 2 root root 4096 May 1 22:17 srv\n drwxr-xr-x 13 root root 0 Jun 12 15:00 sys\n drwxrwxrwt 2 root root 4096 Jun 12 16:17 tmp\n drwxr-xr-x 10 root root 4096 May 1 22:17 usr\n drwxr-xr-x 12 root root 4096 Jun 12 13:16 var\n lrwxrwxrwx 1 root root 29 May 1 22:18 vmlinuz -> boot/vmlinuz-3.2.0-23-generic\n\nFor interacting with tail-like scripts, we can use the tail function (please see\n`paramiko_expect-tail-demo.py `_\nfor the complete code):\n\n.. code:: python\n\n # Connect to the host\n client.connect(hostname=hostname, username=username, password=password)\n\n # Create a client interaction class which will interact with the host\n interact = SSHClientInteraction(client, timeout=10, display=False)\n interact.expect(prompt)\n\n # Send the tail command\n interact.send('tail -f /var/log/auth.log')\n\n # Now let the class tail the file for us\n interact.tail(line_prefix=hostname+': ')\n\nThe true power of the tail function will become more apparent when you\ncheck out the `Multi-SSH `_\nlibrary. Ever thought about tailing a log on multiple servers? Well\ndream no more my friend, it's here!\n\n\nTests\n-----\n\nNot full coverage yet, and assumes you have docker setup:\n\n.. code:: bash\n\n pip install -r requirements-test.txt\n docker run -d -p 2222:22 -v `pwd`/examples:/examples -v `pwd`/test/id_rsa.pub:/root/.ssh/authorized_keys macropin/sshd\n pytest -s --cov paramiko_expect --cov-report term-missing\n\n\nContributions\n-------------\n\n- Israel Fruchter (@fruch) - Tests / CI / Uploads to Pypi\n- Kiseok Kim (@kiseok7) - Vagrent image\n\n\nLicense\n-------\n\nParamiko Expect is released under the **MIT** license. Please see the\n`LICENSE `_\nfile for more details.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fgimian/paramiko-expect", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "paramiko-expect", "package_url": "https://pypi.org/project/paramiko-expect/", "platform": "Posix", "project_url": "https://pypi.org/project/paramiko-expect/", "project_urls": { "Homepage": "https://github.com/fgimian/paramiko-expect" }, "release_url": "https://pypi.org/project/paramiko-expect/0.2.8/", "requires_dist": null, "requires_python": "", "summary": "An expect-like extension for the Paramiko SSH library", "version": "0.2.8" }, "last_serial": 2876530, "releases": { "0.2.5": [ { "comment_text": "", "digests": { "md5": "d184f2c8eda7d41d8588525265e0dbbd", "sha256": "2c3cfdf885c2ef90db34dbda1d03e10fdf9d3da5d80ffb06a131730c46faa386" }, "downloads": -1, "filename": "paramiko_expect-0.2.5-py2-none-any.whl", "has_sig": false, "md5_digest": "d184f2c8eda7d41d8588525265e0dbbd", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10620, "upload_time": "2017-05-13T20:42:49", "url": "https://files.pythonhosted.org/packages/db/fd/42b5d3809cdd0803db1c7ba33f10d4e78f315e4189c8255ea72a65705707/paramiko_expect-0.2.5-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "865db9fb8832e8e44f7996f676baa1c2", "sha256": "e6b4e9dba6717dd046f97cfd965abd83078ee19e67bba572ad5cb52b22d8eafd" }, "downloads": -1, "filename": "paramiko_expect-0.2.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "865db9fb8832e8e44f7996f676baa1c2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10623, "upload_time": "2017-05-13T20:44:32", "url": "https://files.pythonhosted.org/packages/bc/11/bffeb64908d74886123f25f165ce13f502f499b4ebbf0b03d760a6e4eb40/paramiko_expect-0.2.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7b4c6db59ab2cf9e126618cac70c550e", "sha256": "5b2b4a023c1167a60e5ff5319a7273d7d8fa1ecd17be0d1fc14b1eb3d7954a20" }, "downloads": -1, "filename": "paramiko-expect-0.2.5.tar.gz", "has_sig": false, "md5_digest": "7b4c6db59ab2cf9e126618cac70c550e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8135, "upload_time": "2017-05-13T20:42:35", "url": "https://files.pythonhosted.org/packages/57/98/349d38e921411b39359a34c7f4f12c71f8398757d0f458181a5b33bad2cb/paramiko-expect-0.2.5.tar.gz" } ], "0.2.6": [ { "comment_text": "", "digests": { "md5": "a4a614135fc58d9e7f83566e6448098d", "sha256": "abf962674f9e43a5f4041288d07b8ec0b671e94a0e85f5f01a153a09120f6219" }, "downloads": -1, "filename": "paramiko_expect-0.2.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a4a614135fc58d9e7f83566e6448098d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10830, "upload_time": "2017-05-14T20:38:49", "url": "https://files.pythonhosted.org/packages/b9/79/03709cb1bed5fc049dd9aa563084c60a0172887a035d43ab317467cc6c12/paramiko_expect-0.2.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4758b6da1c61a10fd44225af362546ff", "sha256": "f90db5152afeb39e7b2c342a9774a467eb606a3d0dca955e0158026762fa416a" }, "downloads": -1, "filename": "paramiko-expect-0.2.6.tar.gz", "has_sig": false, "md5_digest": "4758b6da1c61a10fd44225af362546ff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8356, "upload_time": "2017-05-14T20:00:15", "url": "https://files.pythonhosted.org/packages/78/4b/43fe881855cf0cf5911b91e9aafb050e0a31aa3e899e9e703fec1b8c8ef5/paramiko-expect-0.2.6.tar.gz" } ], "0.2.8": [ { "comment_text": "", "digests": { "md5": "b023421144bbb2498a87080698798cf3", "sha256": "e00edef96219c5236c0a9c3dcf7c6dfd57adcb10466497c212f4ddcdde33ccd4" }, "downloads": -1, "filename": "paramiko_expect-0.2.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b023421144bbb2498a87080698798cf3", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 11099, "upload_time": "2017-05-15T21:13:28", "url": "https://files.pythonhosted.org/packages/83/27/a672454cc027ad384b1dec43a95571888546c2e625f00b37204eb16a95f1/paramiko_expect-0.2.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5577bad1edfa4753522299f411313972", "sha256": "a3cc48f7c5b6a716d58619a48697b668d8849c21ed79f2aa27bd326b421f90e6" }, "downloads": -1, "filename": "paramiko-expect-0.2.8.tar.gz", "has_sig": false, "md5_digest": "5577bad1edfa4753522299f411313972", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9023, "upload_time": "2017-05-15T21:02:22", "url": "https://files.pythonhosted.org/packages/92/37/6dbf4eb14431e7a63fd9c89c4122314748d513a78da16badff217398e6f9/paramiko-expect-0.2.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b023421144bbb2498a87080698798cf3", "sha256": "e00edef96219c5236c0a9c3dcf7c6dfd57adcb10466497c212f4ddcdde33ccd4" }, "downloads": -1, "filename": "paramiko_expect-0.2.8-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b023421144bbb2498a87080698798cf3", "packagetype": "bdist_wheel", "python_version": "3.5", "requires_python": null, "size": 11099, "upload_time": "2017-05-15T21:13:28", "url": "https://files.pythonhosted.org/packages/83/27/a672454cc027ad384b1dec43a95571888546c2e625f00b37204eb16a95f1/paramiko_expect-0.2.8-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5577bad1edfa4753522299f411313972", "sha256": "a3cc48f7c5b6a716d58619a48697b668d8849c21ed79f2aa27bd326b421f90e6" }, "downloads": -1, "filename": "paramiko-expect-0.2.8.tar.gz", "has_sig": false, "md5_digest": "5577bad1edfa4753522299f411313972", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9023, "upload_time": "2017-05-15T21:02:22", "url": "https://files.pythonhosted.org/packages/92/37/6dbf4eb14431e7a63fd9c89c4122314748d513a78da16badff217398e6f9/paramiko-expect-0.2.8.tar.gz" } ] }