从部署在cloudfoundry上的spring web应用程序执行shell脚本 [英] Execute shell script from spring web application deployed on cloudfoundry
问题描述
我试图从部署在cloudfoundry上的Spring Web应用程序调用Btrace脚本。
I am trying to call Btrace script from Spring web application deployed on cloudfoundry.
执行命令是/ var / vcap / data / dea / apps / petclinic- 0-fef4b0e052097a0cd2bedb8018c28dcd / tomcat / webapps / ROOT / WEB-INF / classes / bin / btrace.sh 532 / var / vcap / data / dea / apps / petclinic-0-fef4b0e052097a0cd2bedb8018c28dcd / tomcat / WEB-INF /bin/DatabaseQueries.java
The execution command is /var/vcap/data/dea/apps/petclinic-0-fef4b0e052097a0cd2bedb8018c28dcd/tomcat/webapps/ROOT/WEB-INF/classes/bin/btrace.sh 532 /var/vcap/data/dea/apps/petclinic-0-fef4b0e052097a0cd2bedb8018c28dcd/tomcat/webapps/ROOT/WEB-INF/classes/bin/DatabaseQueries.java
但是我收到此错误:
java.io.IOException:无法运行程序 /var/vcap/data/dea/apps/petclinic-0-fef4b0e052097a0cd2bedb8018c28dcd/tomcat/webapps/ROOT/WEB-INF/classes/bin/btrace.sh:java.io.IOException:错误= 13,权限被拒绝
java.io.IOException: Cannot run program "/var/vcap/data/dea/apps/petclinic-0-fef4b0e052097a0cd2bedb8018c28dcd/tomcat/webapps/ROOT/WEB-INF/classes/bin/btrace.sh": java.io.IOException: error=13, Permission denied
我以完全的脚本编写权限推送了应用程序,但错误仍然存在。
I push the app with full permissions to script but error persists.
我们如何执行shell /来自cloudfoundry上的spring Web应用程序的bat脚本
How can we execute a shell/bat script from spring web application on cloudfoundry
推荐答案
推送到Cloud Foundry的文件的权限由文件所有者读取/写入。在运行脚本之前,您需要使脚本可从您的应用程序执行:
Permissions on files pushed to Cloud Foundry are read/write by the file owner. You'll need to make the script executable from your app before running it:
String btracePath = System.getenv().get("HOME") + "/tomcat/webapps/ROOT/WEB-INF/classes/bin/btrace.sh";
String cmd = "chmod +x " + btracePath;
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
try {
pr.waitFor();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
这篇关于从部署在cloudfoundry上的spring web应用程序执行shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!