I am trying to automate three or four bash shell scripts using AppleScriptObjC as a wrapper. This will give me a friendly gui front end to select data files etc., and the convenient text file manipulating and processing of several bash scripts.
Everything works (I can press my buttons and run the shell scripts) except I can't figure out how to make things semi-portable. I would like to have a single app or package that I could distribute to others, with the needed script files somehow incorporated or generated by the app, rather than exposed to the users.
I am a noob to Xcode and AppleScriptObjC (ASOC) and I can't see the way to do this. - I can run the scripts as set of simple do shell script commands, or through commands sent to a terminal window, but that means all the individual shell files have to be distributed and put it the right place as a bunch of pieces. - I have tried to generate the script files from within the ASOC, but I run into barriers constructing the files due to the way that ASOC handles strings and special characters. I have tried both normal strings or the quoted form of string construction. As background, Apple Technical Note TN2065 is relevant. Creating the files that way loses the special characters. This code demonstrates the issue (e.g., what I am doing wrong!):
set scriptName to "/Users/me/Desktop/myScript.sh" -- Name of file
-- Define a multi line string:
set scriptContents to " First Line - OK
Second Line, all good so far
$Test fails - the (dollar sign)Test vanishes
\"$Test\" also fails
Last line"
do shell script ("cd " & myFolder & "; echo \" " & scriptContents & " \" > " & scriptName)
Without a way to create the needed shell scripts from within the ASOC or access the scripts if included in the application bundle as a supporting file, I will be doing a lot of tricky porting from bash to AppleScriptObjC!
Suggestions or solutions would be gratefully accepted: 1. How can I write arbitrary multi-line files with AppleScriptObjC including control characters, etc. 2. or 3. How can I package a shell script so that ASOC can run it when needed?