Discussion:
[Fab-user] Regarding fexpect in fabric python
Kirti Kumbhar
2017-11-24 06:31:10 UTC
Permalink
Hi,

I am using fabric python library for interacting with remote machine
shell.using fexpect but when I send list in with expecting(prompt) then it
doesn't exit from that.
Below I have paste the code snap.

from fabric.api import *
from fabric.context_managers import settings
from ilogue.fexpect import expect, expecting, run


prompts = []
prompts += expect('Username:','admin')
prompts += expect('Password:','admin')
prompts += expect('OPR>','help')
prompts += expect('OPR>', 'show opr-user')


with settings(host_string="***@192.168.1.189", warn_only=True):
env.password = "***@123"
with cd('/home/alef/opr'):
with expecting(prompts):
run('./go_opr_cli', )




after executing run it's control doesn't go to next list element.I want to
help.

Thanks & Regards,
Kirti D Kumbhar
Brandon Whaley
2017-11-24 07:24:52 UTC
Permalink
I gave fexpect a look and it doesn't have any logic to handle instances
where two expectations have the same lookup key. You can see the relevant
code here:
https://github.com/ilogue/fexpect/blob/master/ilogue/fexpect/internals.py#L57

If I were to implement what you want to do, I would either use a dictionary
for prompts on the remote side or have the remote pexpect script remove
entries as they get matched.

On Fri, Nov 24, 2017 at 1:32 AM Kirti Kumbhar <
Post by Kirti Kumbhar
Hi,
I am using fabric python library for interacting with remote machine
shell.using fexpect but when I send list in with expecting(prompt) then it
doesn't exit from that.
Below I have paste the code snap.
from fabric.api import *
from fabric.context_managers import settings
from ilogue.fexpect import expect, expecting, run
prompts = []
prompts += expect('Username:','admin')
prompts += expect('Password:','admin')
prompts += expect('OPR>','help')
prompts += expect('OPR>', 'show opr-user')
run('./go_opr_cli', )
after executing run it's control doesn't go to next list element.I want to
help.
Thanks & Regards,
Kirti D Kumbhar
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Loading...