jsch怎么执行可执行文件(是一个c语言程序) 直接用文件名不行
1条回答 默认 最新
- oyljerry 2015-07-28 08:50关注
这里执行的sh,你换成你c程序路径。
public void cmremove() { try { JSch jsch = new JSch(); Session session = jsch.getSession(user, host, port); UserInfo ui = new SUserInfo(pass, null); session.setUserInfo(ui); session.setPassword(pass); session.connect(); ChannelExec channelExec = (ChannelExec)session.openChannel("exec"); InputStream in = channelExec.getInputStream(); channelExec.setCommand("./repoUpdate.sh"); channelExec.connect(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; int index = 0; while ((line = reader.readLine()) != null) { System.out.println(++index + " : " + line); } int exitStatus = channelExec.getExitStatus(); channelExec.disconnect(); session.disconnect(); if(exitStatus < 0){ System.out.println("Done, but exit status not set!"); } else if(exitStatus > 0){ System.out.println("Done, but with error!"); } else{ System.out.println("Done!"); } } catch(Exception e) { System.err.println("Error: " + e); } }
解决 无用评论 打赏 举报
悬赏问题
- ¥15 程序不包含适用于入口点的静态Main方法
- ¥15 素材场景中光线烘焙后灯光失效
- ¥15 请教一下各位,为什么我这个没有实现模拟点击
- ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
- ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
- ¥20 有关区间dp的问题求解
- ¥15 多电路系统共用电源的串扰问题
- ¥15 slam rangenet++配置
- ¥15 有没有研究水声通信方面的帮我改俩matlab代码
- ¥15 ubuntu子系统密码忘记