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 6228571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:24:47+00:00 2026-05-24T09:24:47+00:00

I’m trying to write a Client/Server using Twisted that will allow the client to

  • 0

I’m trying to write a Client/Server using Twisted that will allow the client to issue remote commands on the server and receive response data in real time. i.e. If I run $> ssh server someProg.sh, I will see the results in ‘real time’, not all at once when the process finishes. Is this sort of thing possible in Twisted? Thanks.

  • 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-24T09:24:48+00:00Added an answer on May 24, 2026 at 9:24 am

    Absolutely. As already noted in a comment, you can do this by connecting to the SSH server directly with Twisted’s “conch” library. This is more scalable (you can open lots of connections without any extra processes) and more portable (it can work on Windows) but it won’t take into account your OpenSSH configuration, and you have to write a bunch of additional code to deal with things like host key verification. The other question doesn’t directly address your main question here, either, which is about the output being processed as it arrives.

    The simple answer is “yes”, but here’s a demonstration program that spawns several subprocesses and displays their output as it goes. You can replace the sys.executable with another program to spawn (i.e. ssh) and it’ll work exactly the same way.

    import os, sys
    
    from twisted.internet.protocol import ProcessProtocol
    from twisted.internet import reactor
    from twisted.internet.defer import Deferred, gatherResults
    
    script = """
    import time
    for x in range(3):
        time.sleep(1)
        print(x)
    """
    
    class SimpleProcess(ProcessProtocol):
        def __init__(self, id, d):
            self.id = id
            self.d = d
        def outReceived(self, out):
            print('Received output: {out} from: {proc}'
                  .format(out=repr(out), proc=self.id))
        def processEnded(self, reason):
            self.d.callback(None)
    
    ds = []
    for x in range(3):
        d = Deferred()
        reactor.callLater(
            x * 0.5, reactor.spawnProcess, SimpleProcess(x, d),
            sys.executable, [sys.executable, '-u', '-c', script],
            os.environ)
        ds.append(d)
    
    gatherResults(ds).addBoth(lambda ignored: reactor.stop())
    
    reactor.run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.