mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manoj kumar <manojkuma...@gmail.com>
Subject How to execute sftp client using apache ssh client
Date Mon, 23 Jan 2012 08:52:54 GMT
Hi,

I want to write sftp Client using apache-sshd mina client api. I am able to
connect to sftp server using apache ssh client but I do not have any idea
how to send sftp command to apache sshd server and how do I get result of
sftp client. I am totally lost. Please guide me. I have confusion on
below *highlighted
code *taken from SshClient.java:

        SshClient client = SshClient.setUpDefaultClient();
        client.start();
        ClientSession session = client.connect("localhost",
port).await().getSession();
        session.authPassword("smx", "smx");
        ClientChannel channel =
session.createChannel(ClientChannel.CHANNEL_EXEC, "ls");

       * ByteArrayOutputStream sent = new ByteArrayOutputStream();*
*        PipedOutputStream pipedIn = new TeePipedOutputStream(sent);*
*        channel.setIn(new PipedInputStream(pipedIn));*
*        ByteArrayOutputStream out = new ByteArrayOutputStream();*
*        ByteArrayOutputStream err = new ByteArrayOutputStream();*
*        channel.setOut(out);*
*        channel.setErr(err);*
*        channel.open().await();*


What I understood from the code is, we are using outstream to send sftp
command in the form of  byte array to sftp server over a channel.
How do I receive response from sftpserver?
If It is not correct way to send sftp command then what is the correct way
to execute sftp command?

Can anybody provide a simple example which sends sftp command and receives
response from sftp server?


-- 
Thanks and Regards,
Manoj Kumar
9535214528

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message