'AppleScript to remove icon from dock

I need to be able to run the script through Terminal only. I've seen other scripts that work as long as you change some settings in Accessibility; this is not an option for what I'm trying to do. I've tried the script below, but receive the following error:

0:13: script error: A real number can’t go after this identifier. (-2740)

tell application "System Events"
      set dockPlistFile to property list file "~/Library/Preferences/com.apple.dock.plist"
      tell dockPlistFile
                tell property list item "persistent-apps"
                          set appTileItems to value of (every property list item whose value of property list item "tile-data"'s property list item "file-label" is not "Terminal")
                          set its value to appTileItems
                end tell
      end tell
end tell
tell application "Dock" to quit

I'm trying to get rid of the Terminal icon from the dock. How can I do this correctly?



Solution 1:[1]

I think this ask different answer will help you run a dock modification without changes to Accessibility settings. Basically you'll chain a launch agent XML file to a shell script and call your apple script from within that.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jorfus