You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Arpan (Jira)" <ji...@apache.org> on 2020/08/28 15:26:00 UTC

[jira] [Updated] (SSHD-1068) ChannelExec not showing the output

     [ https://issues.apache.org/jira/browse/SSHD-1068?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Arpan updated SSHD-1068:
------------------------
    Description: 
I have just started using apache-mina ssh client and ran into a issue where the command output is not printing. Here is the sample code - 
{code:java}
class LibraryBasicTest {

	private static final String USER = "luser";
	private static final String HOST = "192.168.0.179";
	private static final int PORT = 22;
	private static final long DEFAULT_CONNECT_TIMEOUT = 3L;
	private static final long DEFAULT_AUTH_TIMEOUT = 3L;
	private static final long DEFAULT_EXEC_TIMEOUT = 3L;

	@Test
	void basic_user_pass_ssh_conn_tests() {
		SshClient sshClient = SshClient.setUpDefaultClient();
		sshClient.start();
		ClientSession session = null;
		try {
			session = sshClient.connect(USER, HOST, PORT).verify(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS)
					.getClientSession();
			session.addPasswordIdentity("P@ssw0rd");
			session.auth().verify(DEFAULT_AUTH_TIMEOUT, TimeUnit.SECONDS);
			
			ChannelExec channel = session.createExecChannel("sleep 5;echo \"Hello World!\" \n");
			channel.setUsePty(true);
			channel.setOut(System.out);
			channel.setErr(System.err);
			channel.open().verify(DEFAULT_EXEC_TIMEOUT, TimeUnit.SECONDS);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (null != session) {
				try {
					session.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		sshClient.stop();
	}

}


{code}

  was:
I have just started using apache-mina ssh client and ran into a issue where the command output is not printing. Here is the sample code - 
{code:java}
class LibraryBasicTest {class LibraryBasicTest {
 private static final String USER = "luser"; private static final String HOST = "192.168.0.179"; private static final int PORT = 22; private static final long DEFAULT_CONNECT_TIMEOUT = 3L; private static final long DEFAULT_AUTH_TIMEOUT = 3L; private static final long DEFAULT_EXEC_TIMEOUT = 3L;
 @Test void basic_user_pass_ssh_conn_tests() { SshClient sshClient = SshClient.setUpDefaultClient(); sshClient.start(); ClientSession session = null; try { session = sshClient.connect(USER, HOST, PORT).verify(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS) .getClientSession(); session.addPasswordIdentity("P@ssw0rd"); session.auth().verify(DEFAULT_AUTH_TIMEOUT, TimeUnit.SECONDS);  ChannelExec channel = session.createExecChannel("sleep 5;echo \"Hello World!\" \n"); channel.setUsePty(true); channel.setOut(System.out); channel.setErr(System.err); channel.open().verify(DEFAULT_EXEC_TIMEOUT, TimeUnit.SECONDS); } catch (IOException e) { e.printStackTrace(); } finally { if (null != session) { try { session.close(); } catch (IOException e) { e.printStackTrace(); } } } sshClient.stop(); }
}{code}


> ChannelExec not showing the output
> ----------------------------------
>
>                 Key: SSHD-1068
>                 URL: https://issues.apache.org/jira/browse/SSHD-1068
>             Project: MINA SSHD
>          Issue Type: Question
>    Affects Versions: 2.5.1
>            Reporter: Arpan
>            Priority: Minor
>
> I have just started using apache-mina ssh client and ran into a issue where the command output is not printing. Here is the sample code - 
> {code:java}
> class LibraryBasicTest {
> 	private static final String USER = "luser";
> 	private static final String HOST = "192.168.0.179";
> 	private static final int PORT = 22;
> 	private static final long DEFAULT_CONNECT_TIMEOUT = 3L;
> 	private static final long DEFAULT_AUTH_TIMEOUT = 3L;
> 	private static final long DEFAULT_EXEC_TIMEOUT = 3L;
> 	@Test
> 	void basic_user_pass_ssh_conn_tests() {
> 		SshClient sshClient = SshClient.setUpDefaultClient();
> 		sshClient.start();
> 		ClientSession session = null;
> 		try {
> 			session = sshClient.connect(USER, HOST, PORT).verify(DEFAULT_CONNECT_TIMEOUT, TimeUnit.SECONDS)
> 					.getClientSession();
> 			session.addPasswordIdentity("P@ssw0rd");
> 			session.auth().verify(DEFAULT_AUTH_TIMEOUT, TimeUnit.SECONDS);
> 			
> 			ChannelExec channel = session.createExecChannel("sleep 5;echo \"Hello World!\" \n");
> 			channel.setUsePty(true);
> 			channel.setOut(System.out);
> 			channel.setErr(System.err);
> 			channel.open().verify(DEFAULT_EXEC_TIMEOUT, TimeUnit.SECONDS);
> 		} catch (IOException e) {
> 			e.printStackTrace();
> 		} finally {
> 			if (null != session) {
> 				try {
> 					session.close();
> 				} catch (IOException e) {
> 					e.printStackTrace();
> 				}
> 			}
> 		}
> 		sshClient.stop();
> 	}
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org