• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Running ruby (utilizing appscript) from do shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running ruby (utilizing appscript) from do shell script


  • Subject: Re: Running ruby (utilizing appscript) from do shell script
  • From: James Nierodzik <email@hidden>
  • Date: Wed, 4 Jun 2008 09:45:18 -0500

Hi Mark,

The answer to your first question was simply curiosity. I wanted to see if I could and how I would go about doing it. Does it have
a real world practical application? Probably not, but I just wanted to see how it would work =)


As to your solution that did in fact work so thank you. I had tried running a much smaller script that was just basic ruby commands
and that did work, so I was perplexed when this one did not.


To address the the first question again though... what about in the case of a droplet? You want to utilize droplet type functionality, but
leverage something within ruby/appscript for some reason? I don't know if this could or would ever be the case though as I am not
familiar enough with what ruby itself brings to the table.


James Nierodzik

On Jun 4, 2008, at 9:33 AM, Mark J. Reed wrote:

First question: why?  The idea behind appscript is to let you use
something besides AppleScript to do app scripting; if you're going to
use AppleScript anyway, I'm not sure what calling out to
ruby/appscript buys you.

But I suspect you're running into newline issues.  A multiline AS
string has carriage returns between the lines; Ruby  (and UNIX-level
tools generally) expects linefeeds.  Try sticking this in front of the
do shell call:

set text item delimiters to return
set commandLines to text items of theCommand
set text item delimiters to linefeed -- use "ASCII character 10" pre-Leopard
set theCommand to commandLines as text



On Wed, Jun 4, 2008 at 10:14 AM, James Nierodzik <email@hidden> wrote:
Hello scripters,
After reading the recent posts on rb-appscript I decided to give it a whirl.
So I started by just redoing a recent script than came across here and
after a little tinkering I got it to work. From there I wanted to try and
get the ruby code to run from inside an applescript and this is what I have
come up with.


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
set rb to "require 'rubygems'
require 'appscript'
include Appscript
require 'osax'
include OSAX
# Set Duration Params
new_duration = 10
# App Declarations
Finder = app('Finder')
QT = app('QuickTime Player.app')
theFile = osax.choose_file()
theMovie = Finder.files[theFile].name.get
savePath = osax.choose_folder()



QT.open(theFile)
QT.select_all(theMovie)
QT.documents[theMovie].selection_end.set(new_duration *
(QT.documents[theMovie].time_scale.get))
QT.documents[theMovie].trim
QT.documents[theMovie].save_self_contained(:in => (String(savePath) + '/' +
theMovie))
QT.documents[theMovie].close"
set theCommand to "ruby -e \"" & rb & "\""
do shell script theCommand
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Here's where I get lost though. If I copy the contents of theCommand
and paste it into a terminal window the script runs fine. However when it's
ran via the do shell script theCommand I get back this error



-e:1: syntax error, unexpected tIDENTIFIER, expecting $end require 'rubygems' require 'appscript' include Appscript require 'osax' include OSAX # Set Duration Params new_duration = 10 # App Declarations Finder = app('Finder') QT = app('QuickTime Player.app') theFile = osax.choose_file() theMovie = Finder.files[theFile].name.get savePath = osax.choose_folder()

QT.open(theFile)
QT.select_all(theMovie)
QT.documents[theMovie].selection_end.set(new_duration *
(QT.documents[theMovie].time_scale.get))
QT.documents[theMovie].trim
QT.documents[theMovie].save_self_contained(:in => (String(savePath) + '/' +
theMovie))
QT.documents[theMovie].close
^


Any ideas what's going on?
Thanks!

James Nierodzik
P Please consider the environment
before printing this email.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden )
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden




-- Mark J. Reed <email@hidden>

_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Running ruby (utilizing appscript) from do shell script
      • From: Philip Aker <email@hidden>
    • Re: Running ruby (utilizing appscript) from do shell script
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Running ruby (utilizing appscript) from do shell script (From: James Nierodzik <email@hidden>)
 >Re: Running ruby (utilizing appscript) from do shell script (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Running ruby (utilizing appscript) from do shell script
  • Next by Date: Re: Running ruby (utilizing appscript) from do shell script
  • Previous by thread: Re: Running ruby (utilizing appscript) from do shell script
  • Next by thread: Re: Running ruby (utilizing appscript) from do shell script
  • Index(es):
    • Date
    • Thread