Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have been working on this "dashboard" to help control my localhost server environment. It has been scripted in bin/bash for reference. I recently discovered I can use the bin command "osascript" to execute an "AppleScript"-esque command through the Terminal, and am playing around with that to incorporate into my dashboard. This way, I can execute commands and control my localhost server through one window, while in the background it can open separate tasks without obstructing the main window.

Here is my main question revolving this concept, I noticed that upon the execution of an osascript command, it returns the following information: tab 1 of window id 11148.

This is the bash statement from my .sh script:

osascript -e "tell application \"Terminal\" to do script \"cd $devFolder;svn up\""

And this is the output I can see in my terminal:

tab 1 of window id 11197

Originally, I had wanted to have it just open a new tab, but i'm fine with it opening a window as for the purpose of just having it work. So as my question states, is it possible to somehow store or retrieve that window id of the terminal window that was just created? Allowing me to interact with that specific window and control it?

share|improve this question
add comment

2 Answers 2

From AppleScript Editor:

tell application "Terminal"
    set windowInfo to do script "echo \"hi user273298\""
    do script "echo \"hi adayzdone\"" in windowInfo
end tell

EDIT

osascript -e '
tell application "Terminal"
    set windowInfo to do script "echo \"hi user273298\""
    do script "echo \"hi adayzdone\"" in windowInfo
end tell
'
share|improve this answer
    
Not exactly sure how this is supposed to store the output text that was returned when that osascript command was executed. I see that "windowInfo" variable, but I can't access it outside that command. –  ManBearPixel Nov 12 '13 at 16:31
add comment

Add the tab and window id as an in specifier:

tab=$(osascript -e 'tell app "Terminal" to do script "uptime"');osascript -e 'tell app "Terminal" to do script "uptime" in '"$tab"

You can also use in window 1 to run a command in an existing window:

osascript -e 'tell app "Terminal" to do script "uptime"';osascript -e 'tell app "Terminal" to do script "uptime" in window 1'

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.