tags:

views:

75

answers:

2

I have a java program that writes a bash script. Unfortunately when this script is saved, 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...

+9  A: 
bashScriptFile.setExecutable(true);

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

glowcoder
Excellent! Thank you.
Earl Bellinger
+2  A: 

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);
YoK
This method i smore dependent on the platform, chmod being not available everywhere.
Grimmy
This solution should work for mentioned OS ubuntu in question.
YoK