以下是剧本。
string FindGrade(double score,string rule)
{
List<Scoremaster> scores=(from p in dbcontext.Scoremasters
where p.GradeRule==rule
select p).ToList();
//how can i check the score input of the function belongs to which category from this list using Linq
//example FindGrade(3,5) = B2 FindGrade(4,5) = A2
//example FindGrade(7,10) = A2 FindGrade(4,10) = C
//example FindGrade(17,20) = A1 FindGrade(10,20) = B1
}
它只是关闭而启动无效。
我正在运行以下代码
#!/bin/bash
if [ ! -s $CATALINA_HOME ]; then
echo "Error: CATALINA_HOME not set!!!"
exit -1
fi
SHUTDOWN_SCRIPT="$CATALINA_HOME/bin/shutdown.sh"
STARTUP_SCRIPT="$CATALINA_HOME/bin/startup.sh"
#execute shutdown.sh
echo "Doing Shutdown"
$SHUTDOWN_SCRIPT
sleep 5
#execute startup.sh
echo "Doing Startup"
$STARTUP_SCRIPT
exit 0
我在.bat文件中遇到了类似的问题,我用
修复了它Runtime rn = Runtime.getRuntime();
Process proc;
proc = rn.exec("/script/restart.sh");
proc.waitFor();
使用“cmd / c start”调用解决了我的问题。对.sh文件的任何类似建议?
答案 0 :(得分:0)
检查文件权限是否具有执行权限,如果没有设置执行权限。
执行which bash
它会在bash
或/bin/bash yourShell.sh
中使用示例/bin/sh yourShell.sh
或Runtime#exec
返回ProcessBuilder
尝试的路径(推荐)
saravana@ubuntu:~$which bash
/bin/bash
String[] commmands = { "/bin/bash", "/script/restart.sh" }; // or { "/bin/sh", "/script/restart.sh" }
Runtime.getRuntime().exec(commmands); //or
new ProcessBuilder(commmands).start(); //Recommended