I’m really confused, I wrote this code and I’m trying to pull in some functions I defined, but I’m not passing the right information somewhere. Does anyone have any tips or pointers? I’m not sure how to describe what my problem is, but the error is:
Traceback (most recent call last):
File "./test3.py", line 54, in <module>
bar()
File "./test3.py", line 26, in disconnectvpn
child.sendcontrol('c')
NameError: global name 'child' is not defined
My fixed program code looks like this:
def foo():
child = pexpect.spawn ('./script.sh -arg1')
child.expect ('(?i)user input:')
child.sendline ('response')
return child
def bar(child):
child.sendcontrol('c')
a = foo()
bar(a)
connectvpn()andcapture it
disconnectvpn()before using it