ssh登陆后,执行命令不能返回结果,且 getExitStatus 返回为1

feihooone 2008-11-19 03:46:13
情况这样的 我直接用此程序登陆LINUX 系统是没问题的,可以将命令的执行结果返回,且 sess.getExitStatus 的返回是0 正常

但我用此程序登陆 一个设备,操作系统是 Welcome to MontaVista Linux 3.0, Professional Edition
无论执行什么命令都返回下面这样的欢迎信息,不知道是为什么?
而且 sess.getExitStatus 的返回是1


cli 2.1.2
Login from 221.10.44.138 port:22
Press TAB anytime, CLI will help you to finish the command line,
or gives the available keywords.
If you firstly use CLI, you can try "get" command.
For example:
set wlan o(press TAB)
you will get the following:
set wlan operationmode
and press TAB again to see what you will get!


找了一个程序,但每次都返回的是欢迎信息,并没将“get system cpu usage” 结果返回到系统,请高手帮忙分析下。

程序代码:
try
{
/* Create a connection instance */

Connection conn = new Connection(hostname);

/* Now connect */

conn.connect();

/* Authenticate.
* If you get an IOException saying something like
* "Authentication method password not supported by the server at this stage."
* then please check the FAQ.
*/

boolean isAuthenticated = conn.authenticateWithPassword(username, password);

if (isAuthenticated == false)
throw new IOException("Authentication failed.");

/* Create a session */

Session sess = conn.openSession();

sess.execCommand("get system cpu usage");
System.out.println("Here is some information about the remote host:");

/*
* This basic example does not handle stderr, which is sometimes dangerous
* (please read the FAQ).
*/

InputStream stdout = new StreamGobbler(sess.getStdout());
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));

while (true)
{
String line = br.readLine();
if (line == null)
break;
System.out.println(line);
}

/* Show exit status, if available (otherwise "null") */

System.out.println("ExitCode: " + sess.getExitStatus());

/* Close this session */

sess.close();

/* Close the connection */

conn.close();

}
catch (IOException e)
{
e.printStackTrace(System.err);
System.exit(2);
}
...全文
1911 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
fosjos 2008-11-20
  • 打赏
  • 举报
回复
嵌入式?不能用普通的环境测试,最好有第三方提供的jar包,就像mobile开发
boboo_2000_0 2008-11-20
  • 打赏
  • 举报
回复
没做过,这应该和系统有关系。
源码链接: https://pan.quark.cn/s/a4b39357ea24 在本研究中,我们将详细研究如何借助Python执行数据可视化,旨在剖析2018年期间中国四个主要城市——北京、上海、广州以及深圳的空气质量状况。通过绘制反映空气质量指数(AQI)与细颗粒物(PM2.5)变化趋势的图表,我们能够深入理解这些大都市全年的空气环境质量,并明确评估其优良天气所占的比重。 我们必须首先进行数据准备工作。在当前提供的压缩文件内,名为"2018天气"的文件极有可能是数据来源,其中可能收录了涉及四个城市每日空气质量监测的详细信息。这些数据通常涵盖日期、城市名称、AQI数值、PM2.5含量等核心参数。在Python编程环境中,我们惯常运用pandas库来对这类结构化数据进行高效的处理和分析。 1. **数据导入与初步处理**: - 利用`pandas.read_csv()`方法来导入存储为CSV格式的数据资料。 - 数据整理:对数据中的空白项、非正常数值进行修正,保证数据的精确性。 - 调整日期字段的格式,确保其能够适用于时间序列分析的需求。 2. **数据深度分析**: - 针对每个城市的AQI和PM2.5数据执行统计性描述,例如计算平均值、中位数、标准偏差等指标。 - 确定空气质量良好天气的天数,即那些AQI值低于75(依据中国的空气质量评估标准)的日数。 3. **数据呈现**: - 运用matplotlib或seaborn工具绘制折线图,直观展示四个城市在2018年全年的AQI和PM2.5变化动态。 - 可通过采用不同的颜色方案和线条类型来区分不同城市的数据系列。 - 添加必要的图示元素,如日期坐标轴、城市名称标注、图表标题及图例说明,以提升图表的可读...

67,535

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧