bash - Create shell script from Extendscript Toolkit -


As one of the outputs from an AccessScript, I want to create a shell script which can be executed by the user. Here's a very basic example:

  create createShellScript () {var content = "#! / Bin / bash \ ndate"; Var outputFolder = Folder.selectDialog ("Choose where to save:"); Var shFile = new file (output folder. AbsoluteUri + "/shell.sh"); shFile.open ("w"); ShFile.write (content); ShFile.close (); } CreateShellScript ();   

If I take the resulting file ( shell.sh ), run it on chmod + x to make it exjectable, and Then run it, if nothing happens, however, I adjust the above script to create the same content but is a text file? It opens the shell.txt file, copies the content editor into a blank document, and saves it as a .sh file, and then Chmod and to run it, it works fine.

Why does not this extension generate the appropriate .sh file when using this method?

Thanks any help.

S

You need to set line feed character for Unix . For example, shFile.lineFeed = "unix"; .

  function createShellScript () {var content = "#! / Bin / bash \ ndate"; Var outputFolder = Folder.selectDialog ("Choose where to save:"); Var shFile = new file (output folder. AbsoluteUri + "/shell.sh"); ShFile.open ("w"); shFile.lineFeed = "Unix"; ShFile.write (content); ShFile.close (); } CreateShellScript ();    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -