开发者

Writing a bash script from java

开发者 https://www.devze.com 2023-01-08 08:35 出处:网络
I have a java program that writes a bash script. Unfortunately when this script is sav开发者_JAVA百科ed, I need to modify it (ubuntu 10.04) to enable running it as an executable. Any way of circumvent

I have a java program that writes a bash script. Unfortunately when this script is sav开发者_JAVA百科ed, I need to modify it (ubuntu 10.04) to enable running it as an executable. Any way of circumventing this?

I understand that it is a security thing...


bashScriptFile.setExecutable(true);

http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/io/File.html#setExecutable%28boolean%29


If you are not using JDK 1.6 you can do following:

After writting file you can do something like

Runtime.getRuntime().exec("chmod +x "+yourfile.sh);
0

精彩评论

暂无评论...
验证码 换一张
取 消