Java调用Linux命令行若干实例
Executing a CommandSee also e90 Reading Output from a Command.
try {
// Execute a command without arguments
String command = "ls";
Process child = Runtime.getRuntime().exec(command);
// Execute a command with an argument
command = "ls /tmp";
child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
If an argument contain spaces, it is necessary to use the overload that requires the command and its arguments to be supplied in an array:
try {
// Execute a command with an argument that contains a space
String[] commands = new String[]{"grep", "hello world", "/tmp/f.txt"};
commands = new String[]{"grep", "hello world", "c:\\Documents and Settings\\f.txt"};
Process child = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
}
e90. Reading Output from a Commandtry {
// Execute command
String command = "ls";
Process child = Runtime.getRuntime().exec(command);
// Get the input stream and read from it
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) {
process((char)c);
}
in.close();
} catch (IOException e) {
}
e91. Sending Input to a Commandtry {
// Execute command
String command = "cat";
Process child = Runtime.getRuntime().exec(command);
// Get output stream to write from it
OutputStream out = child.getOutputStream();
out.write("some text".getBytes());
out.close();
} catch (IOException e) {
}
相关文档:
整理了一些常用的Linux命令
http://jythoner.javaeye.com/blog/290976
关键字: linux
1.查看系统内核
#uname -a
2.查看cpu信息
#cat /proc/cpuinfo
3.查看内存使用情况
#free -m
4.查看硬盘剩余空间
#df -h
5.查看目录占用空间
#du -hs 目录名
6.查看当前有哪些进程
#ps -A
7.查看当前进程的实 ......
三、VMA和PAGE结构 和mmap函数
1.page 主要成员
atomic_t count;
//这个页的引用数. 当这个 count 掉到 0, 这页被返回给空闲列表.
void *virtual;
//如果页被映射,则表示这页的内核虚拟地址; 否则, NULL.
unsigned long flags;
//描述页状态的一套位标志. 这些包括 ......
bin:该目录存放最常用的基本命令,比如拷贝命令cp、编辑命令vi、删除命令rm等。
boot:该目录包含了系统启动需要的配置文件、内核(vmliuxz)和系统镜像(initrd….img)等。
dev:该目录下存放的是Linux中使用或未使用的外部设备文件(fd代表软盘,hd代表硬盘等),使用这些设备文件可以用操作文件的方式操作设备。
......
open-iscsi:http://www.open-iscsi.org/
iscsi 软件的评价
至于软件表现的强弱如何?此可透过实际的CPU 运算占用(占用百分比愈低愈好)、I/O 传输表现(每秒完成多少个I/O 处理,即IOPS)来评断,另外要重视支持的GbE 层级、错误修正层级,如10GbE 优于1GbE,以及ERL2 优于ERL1 优于ERL0。以及是否支持MPIO,MPIO 指的是一部 ......
ps -ef|grep tomcat 查看正在启动的线程
cd .. 退回上一极
ls 列出当前目录的文件
kill -9 [线程号] 关闭线程
su - root 登陆账号
阅读(0)| 评论(14)| 分享(0) 较新一篇:转:带搜索分页的gird 较旧一篇:疯子 评论| 赞
周帅 2010-01-26 18:23
su - root 登陆账号
周帅 2010-01-26 19:53
......