MacRuby: SSH connection with net/ssh?
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 re开发者_JS百科leased on the AppStore.
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.
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.
精彩评论