从所提到的库的名称来看,您可能希望使用ssh在远程服务器上运行命令。
代码很简单
//Initialize a ConnBean object,参数列表is IP,username,password
connbeanCB=newconnbean('IP ',' username ',' password ' );
//puttheconnbeaninstanceasparameterforsshexecstaticmethodgetinstance (conn bean ) toretrieveasingletonssshexecinstance
ssh=sshexec.getinstance(CB;
//连接到服务器
ssh.connect (;
sampletask=新执行命令(echo 123 );
sh.exec (样本任务;
获得输出也很容易。 只要看看我提供的链接。
resultRES=ssh.exec(task );
if(RES.issuccess ) {
system.out.println (返回代码: ) RES.RC );
system.out.println(sysout: ) RES.sysout );
} else {
system.out.println (返回代码: ) RES.RC );
system.out.println (error message 3360 ) RES.error_msg );
}