3

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...

2 Answers 2

10
bashScriptFile.setExecutable(true);

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

Sign up to request clarification or add additional context in comments.

Comments

2

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);

2 Comments

This method i smore dependent on the platform, chmod being not available everywhere.
This solution should work for mentioned OS ubuntu in question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.