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£¬Ã¦Á˺ÃÒ»Õó×Ó£¬ÉÏÍøÕÒ×ÊÁϵȣ¬ÖÕÓÚ×°ºÃÁË£¬ÏÂÃæ¾Í°ÑÎҵIJ½Öè¸ú´ó¼Ò·ÖÏíһϡ£
¡¡¡¡µÚÒ»²½:¼ì²é³ÌÐò°ü¼°Æä°æ±¾
¡¡¡¡ compat-libstdc++-7.3-2.96.118.i386.rpm
¡¡¡¡ ÔÚlinuxµÄ°²×°ÅÌÉÏ,ÕÒµ½ºóʹÓÃrpm -i compat-libstdc++-7.3-2.96.118.i386.rpm °²×°¼´¿É
¡¡¡¡µÚ ......
LINUXµ÷ÓÅ·½·¨×ܽá
----------------------------------------------------------------------------------------------------------------------------
´ó¶àÊý Linux ·¢²¼°æ¶¼¶¨ÒåÁËÊʵ±µÄ»º³åÇøºÍÆäËû Transmission Control Protocol£¨TCP£©²ÎÊý¡£¿ÉÒÔÐÞ¸ÄÕâЩ²ÎÊýÀ´·ÖÅä¸ü¶àµÄÄڴ棬´Ó¶ø¸Ä½øÍøÂçÐÔÄÜ¡£ÉèÖÃÄں˲ÎÊýµÄ· ......
×÷Òµ¹ÜÀí
1.½«“µ±Ç°”×÷Òµ·Åµ½ºǫ́“ÔÝÍ£”£ºctrl+z
2.¹Û²ìµ±Ç°ºǫ́×÷ҵ״̬£ºjobs
²ÎÊý£º
-l ³ýÁËÁгö×÷ÒµºÅÖ®ÍâͬʱÁгöPID
-r£ºÁгö½öÔÚºǫ́ÔËÐУ¨run£©µÄ×÷Òµ
-s£º½öÁгöÔÝÍ£µÄ×÷Òµ
3.½«ºǫ́×÷ÒµÄõ½Ç°Ì¨´¦Àí£ºfg
fg %jobnumber (%¿ÉÓпÉÎÞ)
4.ÈÃ×÷ÒµÔÚºǫ́ÔËÐУºbg
ctrl ......