读书人

ShellCommand_Java代码中执行shell脚本

发布时间: 2012-10-31 14:37:32 作者: rapoo

ShellCommand_Java代码中执行shell脚本_Process的输入、输出、错误流都需要关闭(3)

public static void executeWithoutResult(String shellFile)    {        //脚本文件为NULL或空值        if (null == shellFile || shellFile.equals(""))        {            logger.warn("ShellCommand shellFile is null.");            return;        }                if (logger.isDebugEnabled())        {            logger.debug("bash " + shellFile);        }                try        {            Runtime.getRuntime().exec("bash " + shellFile);        }        catch (Exception e)        {            logger.error("Execute " + shellFile + " exception:", e);        }    }

读书人网 >编程

热点推荐