|
Prev: amalgalite 0.2.0 Released
Next: Does Ruby have any advantage over Python to create semantic applications?
From: Paul Donaghy on 5 Jul 2008 06:45 Guys i want to open a file on another machine lets say test.txt, read it find (grep) for example the text "localhost" and replace it with a machine name and then close the file. I can connect to the machine using ssh or sftp but as far editing a file I'm not sure how to. Any help much appreciated. -- Posted via http://www.ruby-forum.com/.
From: phlip on 5 Jul 2008 06:59
Paul Donaghy wrote: > Guys i want to open a file on another machine lets say test.txt, read it > find (grep) for example the text "localhost" and replace it with a > machine name and then close the file. I can connect to the machine using > ssh or sftp but as far editing a file I'm not sure how to. > > Any help much appreciated. require 'net/ssh' require 'net/sftp' Net::SSH.start( 'server', 'user', 'password' ) do |session| session.sftp.connect do |sftp| # use sftp to pull the file to a local copy # perform string surgery on the local copy # and use sftp.put_file to copy it back end end |