易截截图软件、单文件、免安装、纯绿色、仅160KB

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 驱动mmap操作


三、VMA和PAGE结构 和mmap函数
 
1.page  主要成员
   atomic_t count; 
//这个页的引用数. 当这个 count 掉到 0, 这页被返回给空闲列表.
void *virtual; 
//如果页被映射,则表示这页的内核虚拟地址; 否则, NULL.
unsigned long flags; 
//描述页状态的一套位标志. 这些包括 ......

Virtio:针对 Linux 的 I/O 虚拟化框架

概而言之,virtio
是半虚拟化 hypervisor 中位于设备之上的抽象层。virtio
由 Rusty Russell 开发,他当时的目的是支持自己的虚拟化解决方案 lguest
。本文在开篇时介绍半虚拟化和模拟设备,然后探索 virtio
的细节。本文的重点是来自 2.6.30 内核发行版的 virtio
框架。
Linux 是 hypervisor 展台。如我的 剖析 ......

Linux/Unix下各种压缩文件的压缩/解压方法

1. gz文件
这种文件可以使用gzip、gunzip、zcat进行解压:
gzip -d file_name
gunzip -d file_name
zcat file_name
2. tar.gz、tgz文件
这种压缩文件使用解压命令和tar命令配合使用,如:
gzip -d file_name.tar.gz
gunzip -d file_name.tgz
zcat file_name
然后执行:
tar xvf file_name.tar
某些版本的t ......

linux作业管理(ctrl+z,fg,jobs,kill等)

作业管理
1.将“当前”作业放到后台“暂停”:ctrl+z
2.观察当前后台作业状态:jobs
参数:
-l 除了列出作业号之外同时列出PID  
-r:列出仅在后台运行(run)的作业
-s:仅列出暂停的作业
3.将后台作业拿到前台处理:fg
fg %jobnumber (%可有可无)
4.让作业在后台运行:bg
ctrl ......

linux常用命令


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
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号