Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6828671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:24:38+00:00 2026-05-26T22:24:38+00:00

I have a problem with getting piping to work with paramiko. This works: ssh

  • 0

I have a problem with getting piping to work with paramiko.

This works:

ssh = paramiko.SSHClient()
[...]
stdin, stdout, stderr = ssh.exec_command("find /tmp")
stdout.read()

This does not work (blocks forever on stdout.read()):

[...]
stdin, stdout, stderr = ssh.exec_command("bash -")
stdin.write("find /tmp\n")
stdin.close()
stdout.read()

Any ideas?

EDIT:

I looked at the source code for paramiko, and ChannelFile.close does not really do anything in terms of communication. So I looked at the channel API, and this seems to work:

stdin.write("find /tmp\n")
stdin.flush()
stdin.channel.shutdown_write()
stdout.read()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:24:38+00:00Added an answer on May 26, 2026 at 10:24 pm

    With some investigation, it appears that stdin.close() does not actually end the bash session. To do that, you could use the bash command exit (stdin.write('exit\n')) or dig into the paramiko Channel object underneath the stdin object:

    stdin.channel.shutdown_write()
    

    If you’d like the bash session to continue for another command, you’ll need to use the channel object directly. The documentation for Channel mentions recv_ready(self) and recv(self, nbytes) which will allow you t check for the data before you try to get it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem getting this JPA query to work on MS SQL Server
I have a major problem getting this to work properly. Here is the deal.
I have this problem getting my newly created php project on Netbeans work on
I have a problem getting boost::multi_index_container work with random-access and with orderd_unique at the
I have a problem with getting my pager-function to work. For some reason it
I have problem getting the dropdown menu to work using Twitter's Bootstrap. Here's my
I have a problem getting the following scenario to work. A student can take
I have a problem getting sorting to work with multiple joined tables. For example:
I have a problem getting matplotlib 1.0.0 to work in Python 2.5.2 ( Ubuntu
Have problem while getting data from Memcached on .NET MVC solution. I have this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.