• 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
Running ruby (utilizing appscript) from do shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Running ruby (utilizing appscript) from do shell script


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

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

  • Follow-Ups:
    • Re: Running ruby (utilizing appscript) from do shell script
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: Re: Script for Auto-login to websites
  • Next by Date: Re: Running ruby (utilizing appscript) from do shell script
  • Previous by thread: Re: Control Universal Access Zoom with AS
  • Next by thread: Re: Running ruby (utilizing appscript) from do shell script
  • Index(es):
    • Date
    • Thread