[quote][b]此段代码我是放在页面上运行的,测试有效[/b](注意:要保证当前您拥有此目录的操作权限才可以,否则没用。所需包:"java.io.*")[/quote]
<%
String sr = "";
String ex = "";
BufferedReader bf = null;
java.lang.Process proc = null;
String [] para = new String[3];
para[0] = "/bin/sh";//固定参数
para[1] = "-c";//固定参数
para[2] = "mkdir /home/testpfb/comp_pfb/shuai12";//在此目录路径下创建一个名为shuai12的文件夹
try
{
proc = Runtime.getRuntime().exec(para);
InputStream instr = proc.getInputStream();
bf = new BufferedReader(new InputStreamReader(instr));
String str;
while((str = bf.readLine()) != null)
{
sr += str ;
}
}
catch(IOException e)
{
ex = e.getMessage();
}
try {
proc.waitFor();
}
catch (InterruptedException e)
{
ex = "process was interrupted";
}
if (proc.exitValue() != 0){
ex = "exit value was non-zero";
}
bf.close();
%>