#24 jsch removes "\\" strings from my command line

open
nobody
None
5
2006-04-24
2006-04-24
obvious
No

Can you help me? jsch removes "\\" strings from my
command line. For example:
JSch jsch = new JSch();
String pwd = "1q2w3e";
UserInfo ui = new MyUserInfo(pwd);
int port = 22;
String user = "Administrator";
Session session = jsch.getSession(user, ip, port);
session.setUserInfo(ui);
session.connect();
Channel channel = session.openChannel("exec");
String cmd = "echo qwerty\\qwerty";
((ChannelExec) channel).setCommand(cmd);
channel.setOutputStream(System.out);
((ChannelExec) channel).setErrStream(System.err);
InputStream in = channel.getInputStream();
channel.connect();
byte[] tmp = new byte[1024];
String result = "";
while (!channel.isEOF() || in.available() > 0) {
Thread.sleep(1000);
while (in.available() > 0) {
Thread.sleep(1000);
int i = in.read(tmp, 0, 1024);
if (i < 0) {
break;
}
result = result + new String(tmp, 0, i);
}
}
System.out.println(result);

Result is "qwertyqwerty". '\' was removed from my
command line.
This is critical for me when I want to get data from
registry in
windows and try to execute something like "reg query
HKEY_LOCAL_MACHINE\\SOFTWARE".

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks