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°²×°Îļþ£º
´ò¿ªÖÕ¶ËÔËÐ ......
bin£º¸ÃĿ¼´æ·Å×î³£ÓõĻù±¾ÃüÁ±ÈÈ翽±´ÃüÁîcp¡¢±à¼ÃüÁîvi¡¢É¾³ýÃüÁîrmµÈ¡£
boot:¸ÃĿ¼°üº¬ÁËϵͳÆô¶¯ÐèÒªµÄÅäÖÃÎļþ¡¢Äںˣ¨vmliuxz£©ºÍϵͳ¾µÏñ(initrd….img)µÈ¡£
dev£º¸ÃĿ¼Ï´æ·ÅµÄÊÇLinuxÖÐʹÓûòδʹÓõÄÍⲿÉ豸Îļþ£¨fd´ú±íÈíÅÌ£¬hd´ú±íÓ²Å̵ȣ©£¬Ê¹ÓÃÕâЩÉ豸Îļþ¿ÉÒÔÓòÙ×÷ÎļþµÄ·½Ê½²Ù×÷É豸¡£
......
IPµØÖ·ÊÇÒ»¸ö32λµÄ¶þ½øÖÆÊý£¬ËüÓɵã·ÖÊ®½øÖƼǷ¨±íʾ£¬Ã¿Ò»¸öÊ®½øÖÆÊý´ú±íÒ»¸ö8λÎÞ·ûºÅÕûÐÍÊý£¬ËùÒÔ·¶Î§ÔÚ0-255Ö®¼ä¡£
Ò»¸öIPµØÖ··ÖÎªÍøÂçµØÖ·ºÍÖ÷»úµØÖ·£¬ÍøÂçµØÖ·Çø·Ö²»Í¬ÍøÂ磬Ö÷»úµØÖ·Çø·ÖÏàÍ¬ÍøÂçÖв»Í¬Ö÷»ú¡£²»Í¬µÄIPµØÖ·ÀàËûÃǵÄÖ÷»úÍøÂçµØÖ·Ò²ÊDz»¹Ì¶¨µÄ£¬A,B,CÀàµØÖ·¶¨ÒåÁËijһÖ÷»úÌØ¶¨µÄIPµØÖ·£ ......
´ÅÅÌÓëĿ¼µÄÈÝÁ¿
ÔÚÎÄ×Ö½Ó¿Úµ×ϲ鿴ĿǰµÄ´ÅÅÌ×î´óÈÝÐíÈÝÁ¿¡¢ÒѾʹÓõôµÄÈÝÁ¿¡¢ ĿǰËùÔÚĿ¼µÄÒÑʹ
ÓÃÈÝÁ¿
Ö¸Áî df [-ahikHTm] [Ŀ¼»òÎļþÃû]
-a £ºÁгöËùÓеÄÎļþϵͳ£¬°üÀ¨ÏµÍ³ÌØÓÐµÄ /proc µÈÎļþϵͳ£»
-k £ºÒÔ KBytes µÄÈÝÁ¿ÏÔʾ¸÷Îļþϵͳ£»
-m £ºÒÔ MBytes µÄÈÝÁ¿ÏÔʾ¸÷Îļþϵͳ£»
......
DBA£ºLinux
ÃæÏò DBA µÄ Linux Shell ½Å±¾¼ò½é
×÷ÕߣºCasimir Saternos
ѧϰһЩÔÚ Linux Éϰ²×°¡¢ÔËÐкÍά»¤ Oracle Êý¾Ý¿âËùÐèµÄ»ù±¾ bash shell ½Å±¾¡£
±¾ÎÄÏà¹ØÏÂÔØ£º
ʾÀý½Å±¾
Oracle Êý¾Ý¿â 10g
2005 Äê 11 Ô·¢±í
´óÔ¼ 7 Äêǰ£¬Oracle ·¢²¼ÁË Linux ÉϵĵÚÒ»¸öÉÌÒµÊý¾Ý¿â¡£´ÓÄÇʱÆð£¬Oracle¡¢Red Hat ºÍ ......