易截截图软件、单文件、免安装、纯绿色、仅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下DB2的安装手把手教学篇

 
今天安装了db2,忙了好一阵子,上网找资料等,终于装好了,下面就把我的步骤跟大家分享一下。
  第一步:检查程序包及其版本
   compat-libstdc++-7.3-2.96.118.i386.rpm
       在linux的安装盘上,找到后使用rpm -i compat-libstdc++-7.3-2.96.118.i386.rpm 安装即可
  第 ......

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

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

linux下apache+php安装常见问题

1、Apache
  在如下页面下载apache的for Linux 的源码包
  http://www.apache.org/dist/httpd/;
  存至/home/xx目录,xx是自建文件夹,我建了一个wj的文件夹。
  命令列表:
  
cd /home/wj
  tar -zxvf httpd-2.0.54.tar.gz
  mv httpd-2.0.54 apache
  cd apache
  ./configure --prefix=/u ......

Linux开启SSH

#pacman -S openssh #安装openssh
安装完成后在/etc/rc.conf的最底部DAEMONS后添加sshd让系统启动时自动启动openssh
DAEMONS=(syslog-ng network netfs crond sshd)
也可手动启动openssl,执行
#/etc/inin.d/sshd start
默认情况下其它电脑是不能通过ssh来访问archlinux的,需要修改两个文件来实现:
/etc/h ......

远程连接Linux (Ubuntu配置SSH服务) 端口22

安装OpenSSH
Ubuntu缺省没有安装SSH Server,使用以下命令安装:
sudo apt-get install openssh-server openssh-client
不过Ubuntu缺省已经安装了ssh client。
配置完成后重起:
sudo /etc/init.d/ssh restart
windows 客户端用putty连接命令shell模式 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号