Created
July 12, 2013 15:31
-
-
Save exarkun/5985343 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Copyright (c) Twisted Matrix Laboratories. | |
# See LICENSE for details. | |
if __name__ == '__main__': | |
import sys | |
import sftpclient_ssh | |
from twisted.internet.task import react | |
react(sftpclient_ssh.main, sys.argv[1:]) | |
from twisted.internet.protocol import Protocol | |
from twisted.internet.endpoints import connectProtocol | |
from twisted.conch.endpoints import SSHSubsystemClientEndpoint | |
from twisted.conch.ssh.filetransfer import FileTransferClient | |
from echoclient_ssh import ConnectionParameters | |
def main(reactor, *argv): | |
parameters = ConnectionParameters.fromCommandLine(reactor, argv) | |
endpoint = parameters.endpointForCommand(b"/bin/cat") | |
d = connectProtocol(endpoint, Protocol()) | |
def gotConnection(proto): | |
conn = proto.transport.conn | |
transferProto = FileTransferClient() | |
e = SSHSubsystemClientEndpoint.existingConnection(conn, b"sftp") | |
d2 = connectProtocol(e, transferProto) | |
d2.addCallback(lambda proto: proto.makeDirectory("/tmp/foo", {})) | |
return d2 | |
d.addCallback(gotConnection) | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment