views:

44

answers:

1

Hi,

I want to make a button inside my GUI that triggers a shell script. How can I do this?

Thanks!

+1  A: 

you need to put

def action_name
  output = `/path/to/your/shell/script`
end

into an action that can be called from the gui. the backtick operator `` makes a system call and returns the standard output of your shell script.

UPD: This is the easy way. If you have a long running shell script you should consider using something like Delayed::Job

jigfox
after that script has been invoked, can I safely use a redirect?
Shyam
I can't think of anything why not, so I would say yes
jigfox
The backticks collect all of the output. So if you redirect after the action it won't be called until after the shell script completes. So the redirect will be fine
Steve Weet