Code Monkey home page Code Monkey logo

Comments (7)

marcelosz avatar marcelosz commented on July 30, 2024

Same issue here!

from paramiko-expect.

fruch avatar fruch commented on July 30, 2024

can you guy share an example ?

from paramiko-expect.

mistergates avatar mistergates commented on July 30, 2024
timeout = 30
display = False
cmd = passwd
password = mynewpassword
exp_dict = {
                "New password: ":"{}".format(password), 
                "Retype new password: ":"{}".format(password), 
                "passwd: all authentication tokens updated successfully.":"\n"
            }
prompts = []
try:
    for prompt in exp_dict:
        prompts.append(prompt)
except Exception:
    print('Error building prompts list from exp_dict!')
    return '!! Failed !!'

try:
    # Create a new SSH client object
    client = paramiko.SSHClient()

    # Set SSH key parameters to auto accept unknown hosts
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

    # Connect to the host
    client.connect(hostname=server, username=myusername, password=mypassword)

    # Create a client interaction class which will interact with the host
    with SSHClientInteraction(client, timeout=timeout, display=display) as interact:           
        interact.send(cmd)
        for prompt in prompts:
            interact.expect(prompts) #expect a prompt for our prompts list
            interact.send(exp_dict[interact.last_match]) #send the value assinged to prompt key
        interact.send('exit')
        interact.expect()
        status = 'Success'
except Exception:
    status = '!! Failed !!'
    pass
finally:
    try:
        client.close()
    except:
        pass

return status

I am experiencing this same problem. Sometimes it returns success, sometimes it returns failure. If I add a 'time.sleep(.2)' after .send(), it seems to return success more often but still not 100%.

from paramiko-expect.

msln1314 avatar msln1314 commented on July 30, 2024

Same issue here!,the not set time.sleep(2),after send,the expect get erro output, especically same time the output out of order after loop send command and expect

from paramiko-expect.

gurucp avatar gurucp commented on July 30, 2024

I am also having the same issue ..

from paramiko-expect.

sureshkotapydev avatar sureshkotapydev commented on July 30, 2024

Facing similar issue. In my case, first partial output coming in self.current_output_clean and then this issue occurs for successive commands.

from paramiko-expect.

a11apurva avatar a11apurva commented on July 30, 2024

Any workarounds or fix yet?

from paramiko-expect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.