Skip to content

Commit 50407e8

Browse files
author
Panos
committed
Added session params
1 parent 88df8f6 commit 50407e8

File tree

4 files changed

+999
-894
lines changed

4 files changed

+999
-894
lines changed

examples/example_echo.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import print_function
22
import os
33
import socket
4+
from datetime import datetime
45

56
from ssh2.session import Session
67
from ssh2.utils import version
@@ -35,20 +36,31 @@
3536

3637
# Channel initialise, exec and wait for end
3738
channel = session.open_session()
38-
channel.execute('echo me')
39-
channel.wait_eof()
40-
channel.close()
41-
channel.wait_closed()
39+
channel.shell()
40+
channel.write("sleep 1; echo this took one second\n")
41+
channel.write("for x in 1 2 3; do sleep 1; echo a line per second for three seconds; done\n")
42+
channel.write("sleep 1; echo this took another second\n")
43+
# channel.execute('echo me')
44+
# channel.send_eof()
45+
# channel.close()
46+
# channel.wait_closed()
4247

4348
# Get exit status
44-
print("Exit status: %s" % channel.get_exit_status())
49+
# print("Exit status: %s" % channel.get_exit_status())
4550

4651
# Print output
52+
start = datetime.now()
53+
channel.send_eof()
54+
channel.wait_eof()
4755
size, data = channel.read()
4856
while size > 0:
4957
print(data)
5058
size, data = channel.read()
5159

60+
print("Exit code: %s" % (channel.get_exit_status()))
61+
end = datetime.now()
62+
print("Took %s seconds" % (end - start).total_seconds())
63+
5264
# SFTP capabilities, uncomment and enter a filename
5365

5466
# sftp = session.sftp_init()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
version=versioneer.get_version(),
103103
cmdclass=cmdclass,
104104
url='https://github.com/ParallelSSH/ssh2-python',
105-
license='LGPLv2',
105+
license='LGPLv2.1',
106106
author='Panos Kittenis',
107107
author_email='22e889d8@opayq.com',
108108
description=('Super fast SSH library - bindings for libssh2'),

0 commit comments

Comments
 (0)