From: has Date: 2007-10-29T09:50:09+09:00 Subject: Re: iTerm and Ruby::OSA On 28 Oct, 17:27, "Matt Mower" wrote: > Hi. > > I wonder if anyone has successfully gotten iTerm to open a new session > within a terminal window and execute commands using RubyOSA? > > http://rubyosa.rubyforge.org/ > > I can do this from the Apple ScriptEditor but not using OSA. The > problem, in a nutshell, is that > > iterm = OSA.app( 'iTerm' ) > > returns an instance of OSA::ITerm::Application where all of the useful > methods for working with terminals & sessions are in > OSA::ITerm::ITermApplication and I cannot seem to find out how to go > from one to the other. Unlike AppleScript, which is very more forgiving of imperfect dictionaries, RubyOSA strictly enforces the structure and content provided by application dictionaries. As a result, any bugs or quirks in an application's dictionary may prevent RubyOSA from accessing some or all of that application's scripting features. Anyway, I think your best solution here would be to use rb-appscript - see my sig for links. Appscript is designed to mimic the way that AppleScript operates as closely as possible, so application compatibility problems are rare. For example, to echo 'hello world' in every session tab of the current terminal window: require 'appscript' include Appscript Iterm = app('iTerm') p Iterm.current_terminal.sessions.write(:text=>'echo "hello world"') HTH has -- http://appscript.sourceforge.net http://rb-appscript.rubyforge.org