Sending data

Top  Previous  Next

Once a connection has been established and user authentication is complete you can then proceed to send data to the SSH server. Sending data to the SSH server is accomplished using the SshOutputStream class. To send data you must first obtain the java.io.OutputStream that is associated with your SSH session. This can be accomplished by invoking the Ssh#getOutputStream method. You can then write data using the OutputStream#write method.

 

Example

 

// get OutputStream

OutputStream out = ssh.getOutputStream();

 

// define command to perform directory listing

String command = "ls –al";

 

// send command to SSH server

out.write(command.getBytes());

 

// write CRLF to indicate end of command

out.write("\r\n".getBytes());





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC