Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You'd need to chmod it, and you can probably do it by exec'ing a system command like such:</p> <p>Really all you'd need is to fire off something like this:</p> <pre><code>Runtime.getRuntime().exec("chmod u+x "+FILENAME); </code></pre> <p>But if you want to keep track of it more explicitly can capture stdin / stderr then something more like:</p> <pre><code>Process p = Runtime.getRuntime().exec("chmod u+x "+FILENAME); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); </code></pre> <p>Which I got from here: <a href="http://www.devdaily.com/java/edu/pj/pj010016/pj010016.shtml" rel="noreferrer">http://www.devdaily.com/java/edu/pj/pj010016/pj010016.shtml</a></p> <p><strong>Update:</strong></p> <p>Test program:</p> <pre><code>package junk; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; public class Main{ private String scriptContent = '#!/bin/bash \n echo "yeah toast!" &gt; /tmp/toast.txt'; public void doIt(){ try{ Writer output = new BufferedWriter(new FileWriter("/tmp/toast.sh")); output.write(scriptContent); output.close(); Runtime.getRuntime().exec("chmod u+x /tmp/toast.sh"); }catch (IOException ex){} } public static void main(String[] args){ Main m = new Main(); m.doIt(); } } </code></pre> <p>On linux if you open up a file browser and double click on /tmp/toast.sh and choose to run it, it should generate a text file /tmp/toast.txt with the words 'yeah toast'. I assume Mac would do the same since it's BSD under the hood.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload