Revision 7c5d2771 examples/baresshd.py

View differences:

examples/baresshd.py
4 4

  
5 5
import sys
6 6
from mininet.node import Host
7
from mininet.util import ensureRoot
7
from mininet.util import ensureRoot, waitListening
8 8

  
9 9
ensureRoot()
10
timeout = 5
10 11

  
11 12
print "*** Creating nodes"
12 13
h1 = Host( 'h1' )
......
33 34
if len( sys.argv ) > 1:
34 35
    cmd += ' ' + ' '.join( sys.argv[ 1: ] )
35 36
h1.cmd( cmd )
37
listening = waitListening( server=h1, port=22, timeout=timeout )
36 38

  
37
print "*** You may now ssh into", h1.name, "at", h1.IP()
39
if listening:
40
    print "*** You may now ssh into", h1.name, "at", h1.IP()
41
else:
42
    print ( "*** Warning: after %s seconds, %s is not listening on port 22"
43
            % ( timeout, h1.name ) )

Also available in: Unified diff