我正在连接到远程服务器SSH服务器并尝试获取特定路径中的文件列表我能够获取路径中的文件列表但是它们处于不可读的格式可能对此有任何帮助
String host="xxxxx.yyyy.com";
String user="user";
String password="password";
String command1="dzdo su - lucy";
try{
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
JSch jsch = new JSch();
Session session=jsch.getSession(user, host, 22);
session.setPassword(password);
session.setConfig(config);
session.connect();
System.out.println("Connected");
Channel channel=session.openChannel("shell");
OutputStream ops = channel.getOutputStream();
PrintStream ps = new PrintStream(ops, true);
channel.connect();
ps.println(command1);
ps.println("ls -ltr");
InputStream in=channel.getInputStream();
byte[] tmp=new byte[1024];
while(true){
while(in.available()>0){
int i=in.read(tmp, 0, 1024);
if(i<0)break;
System.out.print(new String(tmp, 0, i));
}
if(channel.isClosed()){
System.out.println("exit-status: "+channel.getExitStatus());
break;
}
try{Thread.sleep(1000);}catch(Exception ee){}
}
channel.disconnect();
session.disconnect();
System.out.println("DONE");
Run Code Online (Sandbox Code Playgroud)
这是控制台输出
drwxrws---. 2 …Run Code Online (Sandbox Code Playgroud) 我有这样的代码
{name: 'Data Weave'} mapObject {(upper $$ ) : $}
Run Code Online (Sandbox Code Playgroud)
动态获取地图对象和大写字母键。下面是输出
{
"NAME": "Data Weave"
}
Run Code Online (Sandbox Code Playgroud)
当我删除括在“ upper”关键字中的括号时。数据编织会引发这样的错误。
我在数据编织语言中到底在哪里使用括号感到语法混乱。在上面的代码中,为什么需要使用括号。编译器如何解释括号之间的条件或表达式。