-1

I'm running a command file which enables me to double-click. File name: Documents.command runs a process in the background without having a terminal window open; therefore, I'm using & pkill -f -a Terminal to close the terminal app.

It was working before, but now my Documents folder opens more than once. Meaning, if I close the folder within 10 seconds, it opens up again.

script code:

#!/bin/sh

open ~/Documents

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 
nohup osascript -e 'do shell script "'"$DIR"'/Documents.command"' & pkill -f -a Terminal

The log file I've recorded displays the following errors:

ScriptingAdditions/Digital Hub Scripting.osax" cannot be used with the current OS because it has no OSAXHandlers entry in its Info.plist.
osascript: OpenScripting.framework - scripting addition "/System/Library/ScriptingAdditions/StandardAdditions.osax" cannot be used with the current OS because it has no OSAXHandlers entry in its Info.plist.
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" cannot be used with the current OS because it has no OSAXHandlers entry in its Info.plist.
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/pC Finder Injector.osax" cannot be used with the current OS because it has no OSAXHandlers entry in its Info.plist.
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/SIMBL.osax" cannot be used with the current OS because it has no OSAXHandlers entry in its Info.plist.
syntax error -1757.  Couldn't get error text because of error -1757.

What seems to be the problem here?

mklement0
  • 382,024
  • 64
  • 607
  • 775
James Dean
  • 155
  • 1
  • 17
  • Your description is confusing. Why would the folder open again, and how is that related to 10 seconds? How is the log file created? You haven't mentioned what the background process does. Better not to use `-f` with `pkill`, because you're only matching the process _name_, not the full command line. – mklement0 May 13 '17 at 01:02

1 Answers1

-1

It seems that Do shell script works for only scripts (which I thought .command files would be consider a script, apparently not.)

When using .command files in a osascript, I had to do the following for no error(s).

nohup osascript -e 'tell application "Terminal" to do script "'"$DIR"'/Documents.command"'

using the tell application trigger with Terminal worked!

James Dean
  • 155
  • 1
  • 17
  • `do shell script` passes its argument to `/bin/sh -c`, so as long as the `.command` file is executable and has a valid shebang line and the filename is quoted, if necessary, it _should_ work. Try `echo 'echo hi' > t.command; chmod +x t.command; osascript -e 'do shell script "./t.command"'`. `tell application "Terminal" to do script` launches Terminal and runs the script in a window (although without activating it). – mklement0 May 13 '17 at 00:59