以下代码,通过java用ssh连接树莓派,获取EditText里的内容,并执行相应的命令,执行ip a ,ifconfig,touch ssh等命令时没有问题,但是运行roscore,或某个launch文件时,没有任何反应,是什么问题
```java
```java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.testng.annotations.Test;
import java.io.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//import java.security.KeyStore;
//
//import ch.ethz.ssh2.Connection;
public class ssh extends AppCompatActivity {
private Button button;
private TextView TextView;
private EditText editText;
private static String splitStr = "=====================================================";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ssh);
editText=findViewById(R.id.ed);
button=findViewById(R.id.button1);
TextView=findViewById(R.id.TextView1);
shiyan shiyan=new shiyan();
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
String host="192.168.12.161";
int port=22;
String userName="ubtu";
String password="123456";
JSch jsch = new JSch();
Session session = null;
try {
String cc=editText.getText().toString();
session = jsch.getSession(userName, host, port);
session.setPassword(password);
session.setConfig("StrictHostKeyChecking","no");
session.setTimeout(6000);
session.connect();
//建立连接结束
//发送指令
ChannelExec exec = (ChannelExec) session.openChannel("exec");
InputStream in = exec.getInputStream();
exec.setCommand(cc);
exec.connect();
String s = IOUtils.toString(in, "UTF-8");
System.out.println("结果:"+s);
in.close();
} catch (JSchException | IOException e) {
e.printStackTrace();
}
}
});
thread.start();
}
});
}
}
```