Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use spoon to call Mac OS open or osascript #1

Closed
matschaffer opened this issue Oct 23, 2010 · 2 comments
Closed

Can't use spoon to call Mac OS open or osascript #1

matschaffer opened this issue Oct 23, 2010 · 2 comments

Comments

@matschaffer
Copy link

I'm guessing it has something to do with these commands being mac-specific, but I thought I should bring it up since we tripped over it working on redcar.

Here's a sample script that illustrates the issue on rev 560066:

require 'rubygems'
require 'spoon'

open_command = ['open', '-a', 'Finder', '/Applications']
osa_command  = ['osascript', '-e', 'tell application "Terminal" to activate']

method = :spoon

if method == :spoon
  puts "Using spoon"
  Spoon.spawn(*open_command)
  Spoon.spawn(*osa_command)
else
  puts "Using system"
  system(*open_command)
  system(*osa_command)
end
@evilrich
Copy link
Contributor

You should specify the path to open or use spawnp.

Spoon.spawn('/usr/bin/open', '-a', 'Finder', '/Applications')
Spoon.spawnp('open', '-a', 'Finder', '/Applications')

I suspect that part of the reason you are having a problem is that Spoon doesn't handle error codes returned by posix_spawn so you can't easily tell when it fails. I have a fix for this here: 9baec25

@headius
Copy link
Owner

headius commented Jul 25, 2012

The errno fix was incorporated some time ago, and the remainder of this issue is just misuse.

@headius headius closed this as completed Jul 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants