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.
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