Applescript/Terminal 複数タブからコマンドを打つ

複数タブからコマンドを打ちたいとき:

Applescriptを用いる。

参考: 

applescript - How can I write a script to open multiple terminal tabs and execute code in them? - Ask Different

Writing external scripts | Truffle Suite

 

結果:

 

tell application "Terminal"

-- Activate it.

activate

set targetWindow to 0

 

-- Get a window that's not busy.

-- If there are no open windows, open one.

if (count of windows) is greater than 0 then

repeat with currentWindow in windows

if currentWindow is not busy then

set targetWindow to currentWindow

end if

end repeat

else

set targetWindow to window 1

end if

 

-- List Commands

set firstCommand to "cd /Users/username/blockchain_projects/truffle_minernode1"

set secondCommand to "cd /Users/username/blockchain_projects/truffle_node1"

set truffleCommand to "truffle exec /Users/username/blockchain_projects/truffle_minernode1/txcommand.js"

 

-- Tab 1.

do script firstCommand in targetWindow

do script truffleCommand in targetWindow

 

-- Tab 2.

tell application "System Events" to tell process "Terminal" to keystroke "t" using command down

do script secondCommand in targetWindow

do script truffleCommand in targetWindow

 

-- Tab 3

tell application "System Events" to tell process "Terminal" to keystroke "t" using command down

do script secondCommand in targetWindow

do script truffleCommand in targetWindow

end tell
---------

 

truffle スクリプトのJS file:

module.exports = function(callback) {
  web3.eth.sendTransaction({from:"0xcd2a3d9f938..26", to:"0x5199dd5c...85", value: 10})
}