Jsch how to list files along with directories
Posted
by
Rajeev
on Stack Overflow
See other posts from Stack Overflow
or by Rajeev
Published on 2012-09-06T15:36:42Z
Indexed on
2012/09/06
15:37 UTC
Read the original article
Hit count: 384
In the following code when the command ls -a
is executed why is that i see only the list of directories and not any files that are on a remote linux server
JSch jsch = new JSch();
Session session = jsch.getSession(username1, ip1, 22);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
//session.setPassword(password.getText().toString());
session.setPassword(password1);
session.connect();
final ListView mainlist = (ListView)findViewById(R.id.list);
final RelativeLayout rl = (RelativeLayout)findViewById(R.id.rl);
mainlist.setVisibility(View.VISIBLE);
rl.setVisibility(View.INVISIBLE);
String command = "ls -a";
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
channel.setInputStream(null);
((ChannelExec) channel).setErrStream(System.err);
InputStream in = channel.getInputStream();
© Stack Overflow or respective owner