{"id":240,"date":"2006-12-19T18:15:31","date_gmt":"2006-12-20T01:15:31","guid":{"rendered":"http:\/\/www.red-sweater.com\/blog\/240\/applescript-shell"},"modified":"2006-12-19T18:17:35","modified_gmt":"2006-12-20T01:17:35","slug":"applescript-shell","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/240\/applescript-shell","title":{"rendered":"AppleScript Shell"},"content":{"rendered":"<p>A few months ago, Cameron Hayne told me about his nifty <a href=\"http:\/\/hayne.net\/MacDev\/Ash\/\">AppleScript Shell<\/a> (ash), which offers an interactive command-line interface to AppleScript, and lets you do some nifty tricks like &#8220;tracing&#8221; a script&#8217;s execution, printing the resulting value for each executed statement.<\/p>\n<p>\nBut I just discovered something about ash that&#8217;s truly magical. Think &#8220;Remote Script Editor&#8221;! I&#8217;m in a hotel when I realize I need to access some information from an Address Book entry back home. So I ssh into my home computer, and start slogging through the Address Book data folder. Ugh! If only I could easily ask for the scripted information I need. Of course, there&#8217;s osascript, which is where I started heading. But ash makes this process so much easier, because of its interactive and forgiving interface:\n<\/p>\n<p><pre>\r\niBook> .\/ash\r\nWelcome to ash (AppleScript Shell) version 0.60\r\nType: -help for help, type -exit to exit\r\nash> <strong>tell application \"Address Book\"<\/strong>\r\ntell application \"Address Book\"\r\nash tell> <strong>set myPerson to first person whose name is \"John Doe\"<\/strong>\r\ntell application \"Address Book\"\r\n    set myPerson to first person whose name is \"John Doe\"\r\nash tell> <strong>value of phones of myPerson<\/strong>\r\ntell application \"Address Book\"\r\n    set myPerson to first person whose name is \"John Doe\"\r\n    value of phones of myPerson\r\nash tell> <strong>end<\/strong>\r\ntell application \"Address Book\"\r\n    set myPerson to first person whose name is \"John Doe\"\r\n    value of phones of myPerson\r\nend tell\r\n{\"(415) 555-1384\", \"(415) 555-4424\"}\r\nash> \r\n<\/pre>\n<\/p>\n<p>\nSee how ash takes one line at a time, and then when I end the &#8220;tell&#8221; block, it shows me the results of my query. Now I can call my friend even though I&#8217;m nowhere near my Mac.\n<\/p>\n<p>\nYeah, yeah, yeah. Or I could run VNC, or ya know, put phone numbers on my iPod. But this is just one example of a scenario where interactive scripting could be handy through a remote ssh connection.\n<\/p>\n<p>\nAppleScript Shell, check it out!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few months ago, Cameron Hayne told me about his nifty AppleScript Shell (ash), which offers an interactive command-line interface to AppleScript, and lets you do some nifty tricks like &#8220;tracing&#8221; a script&#8217;s execution, printing the resulting value for each executed statement. But I just discovered something about ash that&#8217;s truly magical. Think &#8220;Remote Script [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,20,1],"tags":[],"class_list":["post-240","post","type-post","status-publish","format-standard","hentry","category-applescript","category-hacking","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=240"}],"version-history":[{"count":0,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/240\/revisions"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}