blob: ccb830232bcf467ebce61606a8580223dd3420c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env python2
import expyct
import time
e = expyct.expyct ('/bin/sh -i')
e.timeout=60
e.expect(['#', '\$'])
e.send ('ls -la /\n')
i = e.expect (['foo','(d[aeiou]v)'])
print '\nRead before match>%s<' % e.before
print 'Matched:>%s<' % e.matched
print 'index:', i
i = e.expect(['#', '\$'])
print '\nRead before match>%s<' % e.before
print 'Matched:>%s<' % e.matched
print 'index:', i
e.send('exit\n')
print 'Sent exit'
time.sleep(2)
print 'isAlive:', e.isAlive()
# This should test timeout...
i = e.expect ('#####')
print '\nRead before match>%s<' % e.before
print 'Matched:>%s<' % e.matched
print 'index:', i
|