Sublime Forum

Sublime 2 crashes when I activate it with Applescript

#1

Hi, I am making a small plugin to send code to other applications such as R, Stata and iTerm. I am using Applescript though the system command osascript to achieve this. When I want to reactivate Sublime Text 2 through applescript, it crashes. Below is a minimum example. Any suggestions?

[code]import sublime, sublime_plugin
import os

class ExampleCommand(sublime_plugin.TextCommand):
def run(self, edit):
cmd = “”“osascript -e ‘tell app “Finder” to activate’ “””
cmd2= “”“osascript -e ‘tell app “Sublime Text 2” to activate’ “””

	os.system(cmd)
	os.system(cmd2)[/code]
0 Likes

#2

Thanks sublimator. Your suggestions worked after adding the ‘shell=True’ argument to subprocess.Popen.

subprocess.Popen("""osascript -e 'tell app "Sublime Text 2" to activate' """, shell=True)
0 Likes