|
|
#1 |
|
AppleScript: Return a value to the Terminal?
Hi Guys,
I'm starting to learn AppleScript after moving from Windows. How do I return a string back to the terminal after executing an AppleScript? Thanks! -Rachit |
|
|
|
0
|
|
|
#2 |
|
Use return:
Code:
return "hello world" |
|
|
|
0
|
|
|
#3 |
|
Hey,
I tried that, I saved it as an executable and then I went in terminal and typed "open test.app" and it opened and closed without outputting anything. Am I supposed to include anything else in the program code other than that one line? |
|
|
|
0
|
|
|
#4 | |
|
I think you want osascript instead. In Terminal type "man osascript" for more info.
AppleScript is more suited for working with applications, not running as a command-line tool. You might be better off using another language, such as Python or Ruby. What are you trying to do? Edit: found this (new in Snow Leopard) Quote:
Last edited by kainjow; Dec 16, 2009 at 01:11 AM. |
||
|
|
0
|
|
|
#5 |
|
|
0
|
|
|
#6 |
|
Oh, I see.
What I'm trying to do is make an app (cross platform) that has to be able to tell what song you're listening to on iTunes. I don't know C, so I chose to go with Adobe Air because i'm a web developer and can basically write the adobe air app in javascript/html. Adobe Air on mac will call on an applescript via command line to find out what song is currently being played, because I don't see any other way to do it. When on Windows, it'll open a different program that works on Windows via command line. The reason I chose AppleScript to work with Adobe Air is because finding what the name of the current track being played is very simple in AppleScript, and I couldn't find a simple example in C that I would be able to compile! -Rachit |
|
|
|
0
|
|
|
#7 |
|
Yea, AppleScript is the right choice for what you want.
This may do what you need ![]() Code:
osascript -e "tell application \"iTunes\" to return name of current track" |
|
|
|
0
|
|
|
#8 |
|
Thanks, I'm getting an error when I run this, though:
Rachit-Guptas-MacBook esktop silver$ osascript -e "tell application \"iTunes\" to return name of current track"2009-12-16 11:56:58.538 osascript[2894:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers. Young Forever [Ft. Mr. Hudson] The last line, however, is the song that I'm listening to. |
|
|
|
0
|
|
|
#9 |
|
Google it. Search terms: ScriptingAdditions Adobe Unit Types
From the first page of results: http://blogs.adobe.com/jnack/2009/09...ith_ps_sl.html http://www.davidchinphoto.com/snow-l...it-types-osax/ |
|
|
|
0
|
|
|
#10 |
|
Ah, thank you very much!
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Resolved: Elegant way to cycle through NSArray from middle index value to the one preceding it? | GorillaPaws | Mac Programming | 8 | Aug 17, 2011 11:08 PM |
| The Terminator Had Love Child with his Maid | Huntn | Politics, Religion, Social Issues | 38 | May 21, 2011 12:53 PM |
| Terminal, add text to the end of all text files in a directory. | Jesse Smith | Mac Basics and Help | 2 | Feb 22, 2011 02:13 PM |
| A Guide to the Terminal, bash, and the UNIX side of Mac OS X | wrldwzrd89 | Mac OS X | 20 | Nov 25, 2009 04:59 PM |
| Switching from Mac OS X to the terminal (like XWindows to Terminal 2 in Linux/Unix) | awulf | Mac Help/Tips | 1 | Dec 6, 2002 08:27 PM |
All times are GMT -5. The time now is 10:31 PM.








esktop silver$ osascript -e "tell application \"iTunes\" to return name of current track"
Linear Mode

