Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Newbie: Paste terminal output with applescript

Newbie: Paste terminal output with applescript
Thread Tools
Junior Member
Join Date: Oct 2001
Location: East Coast, U.S.
Status: Offline
Reply With Quote
Feb 13, 2002, 01:42 PM
 
I am trying to build a script that will paste the output of a shell
command (fortune) to whatever application is currently open. (I want a to use a keystroke to insert a randomized signature into whatever app I am using) This is my
first attempt at script writing, and I realize my script so far doesn't work.


• ****SO FAR***** on run
   tell application "Terminal"
      activate

set the clipboard to (do script with command
"/Users/ami/bin/fortune /Volumes/Britches/documents/mdb/sig_fortunes")

end tell
   paste the clipboard
end run


• *****END*****

I know I need some sort of "paste the clipboard into the current
application"

but I can't figure out how to do it.

If I take out "set the clipboard to" and "paste the clipboard" the
script sucessfully opens a shell and runs the command, but of course it
is not pasted into the application that was originally open.

Any help would be appreciated,
Adam
     
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Feb 13, 2002, 03:07 PM
 
no idea about applescript, but why don't you just pipe the command's output to pbcopy?

i mean, try typing "ls | pbcopy" in terminal.app and you have ls's output in your clipboard.

in cocoa, you can easily set one nstask's output as another one's input; no idea how to do that in applescript, sorry.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:41 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2