-1

I'm looking for creating a connection using ssh in order to execute some command on a remote server.

I wanted to perform these action with the following gem: net/ssh.

But it seems to don't be working with MacRuby.

What would you propose for it?

I would like my application to be released on the AppStore.

Arkan
  • 6,196
  • 3
  • 38
  • 54
  • I've got it working just fine on a mac. What version of ruby have you got? what are the errors you are getting? – HRÓÐÓLFR Jul 19 '11 at 04:06
  • I'm using MacRuby. Net/SSH gem works fine with ruby 1.9 but not with MacRuby(http://www.macruby.org) – Arkan Jul 19 '11 at 04:18
  • Maybe there is a Framework with Cocoa that I could use with MacRuby ? But I didn't find anything ... :( – Arkan Jul 20 '11 at 05:48
  • It looks like just a bug in MacRuby (see http://www.macruby.org/trac/ticket/530) and looks unfixed... so I guess the solution is to use Ruby 1.9 (or fix the bug, I'm sure they'd love a patch). – HRÓÐÓLFR Jul 20 '11 at 16:37

2 Answers2

0

Try this:

framework 'Cocoa'

task = NSTask.new
task.setLaunchPath("/usr/bin/ssh")
task.setArguments(NSArray.arrayWithObjects("user@host", "touch", "tmp/test.txt", nil))
task.launch

This will execute $ touch tmp/test.txt on the remote host.

Jake
  • 715
  • 7
  • 15
0

Have you considered using an NSTask? it is pretty easy to dispatch an ssh command by means of an NSTask. See examples on http://www.cocoadev.com/index.pl?NSTask (of course you'd have to translate calls in macruby equivalents). The advantage is that this way you would not depend on external libraries/gems, so your app would be more easily accepted on the mac app store.

p4010
  • 943
  • 7
  • 19