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ÅäÖÃjava¿ª·¢Æ½Ì¨
Ò»¡¢°²×°jdk
1.ÏÂÔØ°²×°jdk
£¨1£©¡¢Ê×ÏÈ£¬ÔÚhttp://java.sun.com
ÕÒµ½ÒªÏÂÔصÄjdk£¬ÏÂÔØ×Ô¼ºÐèÒªµÄjdk°æ±¾¡£ÎÒÕâÀïʹÓõÄÊÇjdk6£¬µÃµ½µÄÊÇÒ»¸öÃûΪjdk-6u6-linux-i586-rpm.binµÄÎļþ¡£´ËÎļþµ±Ç°Îª²»¿ÉÔËÐеÄshell script¡£
£¨2£©¡¢¸ü¸ÄȨÏÞ£¬ÌáÈ¡jdk°²×°Îļþ£º
´ò¿ªÖÕ¶ËÔËÐ ......
½ñÌì°²×°ÁËdb2£¬Ã¦Á˺ÃÒ»Õó×Ó£¬ÉÏÍøÕÒ×ÊÁϵȣ¬ÖÕÓÚ×°ºÃÁË£¬ÏÂÃæ¾Í°ÑÎҵIJ½Öè¸ú´ó¼Ò·ÖÏíһϡ£
¡¡¡¡µÚÒ»²½:¼ì²é³ÌÐò°ü¼°Æä°æ±¾
¡¡¡¡ compat-libstdc++-7.3-2.96.118.i386.rpm
¡¡¡¡ ÔÚlinuxµÄ°²×°ÅÌÉÏ,ÕÒµ½ºóʹÓÃrpm -i compat-libstdc++-7.3-2.96.118.i386.rpm °²×°¼´¿É
¡¡¡¡µÚ ......
¸Å¶øÑÔÖ®£¬virtio
ÊÇ°ëÐéÄ⻯ hypervisor ÖÐλÓÚÉ豸֮ÉϵijéÏó²ã¡£virtio
ÓÉ Rusty Russell ¿ª·¢£¬Ëûµ±Ê±µÄÄ¿µÄÊÇÖ§³Ö×Ô¼ºµÄÐéÄ⻯½â¾ö·½°¸ lguest
¡£±¾ÎÄÔÚ¿ªÆªÊ±½éÉÜ°ëÐéÄ⻯ºÍÄ£ÄâÉ豸£¬È»ºó̽Ë÷ virtio
µÄϸ½Ú¡£±¾ÎĵÄÖصãÊÇÀ´×Ô 2.6.30 Äں˷¢ÐаæµÄ virtio
¿ò¼Ü¡£
Linux ÊÇ hypervisor չ̨¡£ÈçÎÒµÄ ÆÊÎö ......
ÔÎĵØÖ·
À¶É«±íʾĿ¼£»
ÂÌÉ«±íʾ¿ÉÖ´ÐÐÎļþ£»
ºìÉ«±íʾѹËõÎļþ£»
dzÀ¶É«±íʾÁ´½ÓÎļþ£»
»ÒÉ«±íʾÆäËüÎļþ£»
ºìÉ«ÉÁ˸±íʾÁ´½ÓµÄÎļþÓÐÎÊÌâÁË£»
»ÆÉ«ÊÇÉ豸Îļþ£¬°üÀ¨block, char, fifo¡£
ÓÃdircolors
-p¿´µ½È±Ê¡µÄÑÕÉ«ÉèÖ㬰üÀ¨¸÷ÖÖÑÕÉ«ºÍ“´ÖÌ唣¬Ï»®Ïߣ¬ÉÁ˸µÈ¶¨Òå¡£ ......
Òª½«Îļþϵͳ¹ÒÔص½ÎÒÃÇµÄ Linux ϵͳÉÏ£¬
¾ÍҪʹÓà mount Õâ¸öÖ¸Áî
Ó÷¨:
mount [-tonL] ×°ÖÃÃû³Æ´úºÅ ¹ÒÔصã
mount -a
²ÎÊý£º
-a £ºÒÀÕÕ /etc/fstab µÄÄÚÈݽ«ËùÓÐÏà¹ØµÄ´ÅÅ̶¼¹ÒÉÏÀ´£¡
-n £ºÒ»°ãÀ´Ëµ£¬µ±ÎÒÃǹÒÔØÎļþϵͳµ½ Linux ÉÏͷʱ£¬ Linux »áÖ÷¶¯µÄ½«
&nbs ......