It states to use the syntax do shell script “command &> file_path &”
However, I would like to use a longer and variable command.
For instance previously, I would use a variable to store the commands and then do shell script.
set custom_command to " various commands "
do shell script custom_command
However, this does not work with the above syntax:
do shell script “custom_command &> file_path &”
I get the error message “sh: line 1: custom_command: command not found”
Is there a solution to this?
The reason I ask, is that I have a shell script that can take up to 20 minutes to complete and I want the user to get some feedback as to what is happening. Currently, I have the Terminal open and run the script as visual feedback, but I rather have my app show the feedback instead.
Now the next step… how can I read the text file and output it in relative realtime?
I tried something like this:
do shell script command & " &> ~/example.txt &"
set text_loc to ":example.txt" (EDIT: Not actual path to file, just an example)
set theText to (read file text_loc)
set content of text field "output" of window "Main" to theText
EDIT: Error fixed: (But I get a “End of file error (-39)”)
It will output to the text field once, but I would like it to continue to update the text field as the script is running and writing to the file example.txt