All pastes #359062 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-16 15:04 UTC
rendered paste body
#! /usr/bin/python

from twisted.internet import reactor, defer
from twisted.internet.protocol import ProcessProtocol

def spawnConnection(protocol, args):
    childFDs = {0:"w", 1:"r"}
    print "spawn", repr(args)
    reactor.spawnProcess(
        protocol, "/usr/bin/ssh", args=args, childFDs=childFDs)

class Protocol(ProcessProtocol):

    def outReceived(self, data):
        print "received", data

    def connectionMade(self):
        self.transport.write('Hello\n')


def main():
    spawnConnection(Protocol(), ['ssh', 'localhost'])
    reactor.run()

if __name__ == '__main__':
    main()