Need to step through text in Variable

My script starts out by connecting to another machine via SSH and
reading the hosts file into a variable:

z = ssh -l username -i /home/username/.ssh/id_rsa 10.1.1.1 cat /etc/hosts

Normally if the hosts file was on my local machine, I would be able to
step through the contents of the file line by line and make decisions
based on REGEX using the file open commands.

I don’t want to have to write the contents of my variable to a file and
then open and step through it that way.

What would be the best way to step through my z variable line by line
and match on the content with REGEX?

thanks

jack

Hello Jack

What would be the best way to step through my z variable line by line
and match on the content with REGEX?

z.split(/\n/).each do |line|

end

should do what you are looking for.

Cheers,

thanks alot Jean-Julien…that works perfectly!

jack

2010/3/16 jackster the jackle [email protected]:

thanks alot Jean-Julien…that works perfectly!

Somehow my response to the newsgroup is delayed. You do not need
#split. You can do

ssh ....each_line do |line|

end

This works at least in 1.8.7 and 1.9, probably also in 1.8.6.

Kind regards

robert

Robert K. wrote:

Better still!

thanks alot Robert