2

I want to execute another ruby script from my Shoes app. I try

button "..." do
  `ruby -rubygems /Users/kemiisto/Desktop/Ruby/gears.rb`  
end

but nothing happens. In the case of other commands, for example

button "..." do
  `open /Applications/TextEdit.app/`  
end

all works fine. Any ideas?

3
  • Looks like it should work. What is the question? command gives you the output; system('command') gives you the exit code.
    – Josh Lee
    Jan 13, 2009 at 14:24
  • 2 Martin Carpenter - no error messages. 2 jleedev - the question is how to start 3d party application.
    – kemiisto
    Jan 13, 2009 at 14:35
  • @kemiisto: You can (and should) edit your own question. So others can see the additional info right away.
    – Tomalak
    Jan 13, 2009 at 14:40

5 Answers 5

2

Things are happening, you're just not doing anything with the text that your commands are returning. When you run a system command via 'system' or backticks each command returns whatever the command dumped to STDOUT.

Shoes.app do
  @s = stack {}

  button "go!" do
    @out = `ls -al`
    @s.clear { para @out }
  end
end
1
  • My script does not return any text. It is simple OpenGl Demo script.
    – kemiisto
    Jan 13, 2009 at 15:49
1

This is maybe strange way. But I think works.
Maybe you use Mac ?(from your path),This code works in windows.
If on Mac, I think you can send command to terminal after execute terminal.
or execute applescript from ruby.

Hope this below idea help you(for win).

require 'win32ole'

...some code...

button "..." do
  @auto = WIN32OLE.new('AutoItX3.Control')
  @auto.Run('cmd.exe','',@SW_MAXIMIZE)
  @auto.WinActivate("C:\WINDOWS\system32\cmd.exe")
  @auto.ControlSend("[CLASS:ConsoleWindowClass]", "", "", 'ruby -rubygems /Users/kemiisto/Desktop/Ruby/gears.rb')
end
0

I'd try running

    Shoes.app do
        @s = stack {}
        button "debug" { @s.clear { para `which ruby` } }
    end

so you can see which invocation of ruby it's calling, and work from there

Even better, if open is working, try changing your invocation of ruby to /usr/bin/env ruby.

1
  • At first I thought that the usage of full path is solution. I try /usr/local/bin/ruby instead of ruby. It works from terminal as before, but not from Shoes app. (((
    – kemiisto
    Jan 14, 2009 at 14:43
0

How about a simple require? It definitely works, but I can think of nothing to trace back what's really going on after (apart from the true, returned by require if everything is alright)... Although system wouldn't be much more informative in this scenario.

0
load

may work better than

require

for you here. Require will only load something once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.