Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell usage last read hang #50

Closed
HenGold opened this issue Oct 22, 2018 · 4 comments
Closed

Shell usage last read hang #50

HenGold opened this issue Oct 22, 2018 · 4 comments

Comments

@HenGold
Copy link

HenGold commented Oct 22, 2018

HI
i tried to use execute but i figure out that execute is for single command
i need to run continues commands without initiate new session each time
i tried to use read/write cycles but the read hang on the last iteration

code:

        self.ssh_session.flush()
        self.ssh_session.write(cmd + '\n')
        if delay > 0:
            time.sleep(delay)
        size, data = self.ssh_session.read()
        while size > 0:
            self.report.debug(data)
            size, data = self.ssh_session.read()
        return data

Thanks

@pkittenis
Copy link
Member

pkittenis commented Oct 22, 2018

Hi there,

Thanks for the interest. Issue tracker is for bugs/feature requests with the code, this is better asked on the mail group.

execute requires a new channel (not session) for each command. Interactive shell can be used instead, though execute cannot be used in the case, will have to read/write from shell manually.

If you are looking for a higher level client, see paralell-ssh.

@HenGold
Copy link
Author

HenGold commented Oct 22, 2018

Hi
i know that shell require read/write cycle
but the last read hang.. this is all about

do you suggest to use paralell-ssh?

anyhow to reopen the issue?

@pkittenis
Copy link
Member

The read hangs because there is no more data to be read. On interactive channels no EOF is sent by server to indicate channel has finished. That is expected behaviour of the API in blocking mode. Will need to check if there is anything pending to be read presumably by either Session.block_directions or Channel.poll_read - haven't tried it.

This project is a wrapper to libssh2, similar code is needed to use it directly as for using libssh2. There are not examples for doing everything not even for libssh2 C code. PRs welcome.

If a more higher level client is what is needed, see parallel-ssh. It has both parallel and single host high level clients based on this project.

@HenGold
Copy link
Author

HenGold commented Oct 23, 2018

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants