问题:如何获得命令行的打印信息到程序中
[解决]
python版一直在用,总结一下:
add:http://www.360doc.com/content/13/1226/23/8504707_340405307.shtml
ss=os.popen("1.sh").readlines()
print ss
#获得sh脚本打印内容并输出
[popexizhi]获得python 的print的输出值
self.__console__=sys.stdout
-------------------------------------------------
java版
add:http://zhidao.baidu.com/question/541158774.html
//测试cmd打印导入
import java.lang.System;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
//testcmd 打印信息
try {
Process child=Runtime.getRuntime().exec("ping 192.168.20.10");
final InputStream inputStream = child.getInputStream();
final BufferedReader brOut = new BufferedReader(new InputStreamReader(inputStream));
String line = null;
while ((line = brOut.readLine()) != null) {
//将文本打印到控制台
System.out.println(line);
}
} catch (IOException e1) {
e1.printStackTrace();
}
[解决]
python版一直在用,总结一下:
add:http://www.360doc.com/content/13/1226/23/8504707_340405307.shtml
ss=os.popen("1.sh").readlines()
print ss
#获得sh脚本打印内容并输出
[popexizhi]获得python 的print的输出值
self.__console__=sys.stdout
-------------------------------------------------
java版
add:http://zhidao.baidu.com/question/541158774.html
//测试cmd打印导入
import java.lang.System;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
//testcmd 打印信息
try {
Process child=Runtime.getRuntime().exec("ping 192.168.20.10");
final InputStream inputStream = child.getInputStream();
final BufferedReader brOut = new BufferedReader(new InputStreamReader(inputStream));
String line = null;
while ((line = brOut.readLine()) != null) {
//将文本打印到控制台
System.out.println(line);
}
} catch (IOException e1) {
e1.printStackTrace();
}
没有评论:
发表评论