File tree Expand file tree Collapse file tree 4 files changed +999
-894
lines changed
Expand file tree Collapse file tree 4 files changed +999
-894
lines changed Original file line number Diff line number Diff line change 11from __future__ import print_function
22import os
33import socket
4+ from datetime import datetime
45
56from ssh2 .session import Session
67from ssh2 .utils import version
3536
3637# Channel initialise, exec and wait for end
3738channel = 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 ()
4755size , data = channel .read ()
4856while 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()
Original file line number Diff line number Diff line change 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' ),
You can’t perform that action at this time.
0 commit comments