Writing a bash script from java
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);
精彩评论