Tomcat部署:使包含的脚本可执行(Tomcat deploy: make included scripts executable)

编程入门 行业动态 更新时间:2024-10-18 12:26:26
Tomcat部署:使包含的脚本可执行(Tomcat deploy: make included scripts executable)

我在Windows 7上使用netbeans开发WebApplication(用于Tomcat)。要运行Web应用程序,我需要运行一次insall-script。

这个脚本(* .bat for windows和* .sh for linux包含在我的war-file(WEB_INF)中。

现在每次我部署WAR文件并想在linux上运行脚本时我都要调用

chmod +x install.sh

第一。

是否有一种方法可以使此脚本默认可执行? 我不希望在部署之后执行一些额外的命令以使脚本可执行。

为了澄清:我不是Linux的新手,我知道如何在文件上设置可执行权限。 那不是问题。 我的问题是:我需要做什么,以便在tomcat部署我的* .war文件(解压缩后)后立即执行此脚本。 如果我也将使用Linux进行开发,我会尝试根据我的来源设置权限(也许我会在我有更多的业余时间时尝试)。 但我使用的是Windows和netbeans。

是否有任何我可以设定的属性来实现我的目标,或者是否有可能使用蚂蚁实现这一目标?

顺便问一下:这种方法是否存在与安全相关的问题? 该脚本查找java可执行文件并调用基于javabased的GUI安装程序...

I'm devellopping a WebApplication (for Tomcat) using netbeans on Windows 7. For the Webapplication to run I need to run a insall-script once.

This script (*.bat for windows and *.sh for linux is included in my war-file (WEB_INF).

Now everytime I deploy the WAR-file and want to run the script on linux I have to call

chmod +x install.sh

first.

Is there a way that this script can be made executable by default? I don't want to have to execute some extra commands after the deploy to make the script executable.

For clarification: I'm not new to Linux and I know how to set executable-rights on files. That's not the problem. My problem is: What do I have to do, so that this script is executable right after tomcat deployed my *.war-file (unpacked it). If I would be using Linux for development as well, I would try to set the rights according in my sources (maybe I'll try it when I have a little more spare time). But I am using Windows and netbeans.

Are there any attributes I can set to achive my goal, or is it possible to achive this using ant?

By the way: Are there security related issues with this approach? The script looks for java executable and calls a javabased GUI-installer...

最满意答案

在应用程序初始化期间更改权限,如下所示:

String [] command = {"/bin/chmod","+x",full_path_to_install.sh}; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec( command ); pr.waitFor();

允许您的应用程序在使用脚本之前设置可执行权限。 在tomcat部署war文件之后,但在应用程序使用它之前,它不可执行。

Change permissions during initialization of the application, the following:

String [] command = {"/bin/chmod","+x",full_path_to_install.sh}; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec( command ); pr.waitFor();

allows your application to set executable permissions before using the script. It is not executable right after tomcat deployed your war file but just before your application uses it.

更多推荐

本文发布于:2023-08-05 23:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1440946.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:可执行   脚本   Tomcat   deploy   executable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!