File: test_ssh_fileserver.rst

package info (click to toggle)
execnet 2.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 684 kB
  • sloc: python: 5,244; makefile: 78; sh: 2
file content (21 lines) | stat: -rw-r--r-- 573 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Receive file contents from remote SSH account
-----------------------------------------------------

Here is some small server code that you can use to retrieve
contents of remote files:

.. include:: servefiles.py
    :literal:

And here is some code to use it to retrieve remote contents::

    import execnet
    import servefiles
    gw = execnet.makegateway("ssh=codespeak.net")
    channel = gw.remote_exec(servefiles)

    for fn in ('/etc/passwd', '/etc/group'):
        channel.send(fn)
        content = channel.receive()
        print(fn)
        print(content)