From: darren kirby Date: 2006-06-03T06:05:41+09:00 Subject: Re: Exceptions inside loops... --nextPart1303285.D6Kjd1O4IS Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline quoth the Mike Fletcher: > darren kirby wrote: > >> begin telnetPorts.each do |port| > > > > puts "Port " + port.to_s + ":" > > t =3D TCPSocket.new(host,port) > > banner =3D t.gets > > t.close > > end > > > > rescue SystemCallError > > puts "Unable to connect to port: " + $! > > end > > I believe you just need to move your exception handling inside the > each's block > > telnetPorts.each do |port| > begin > puts "Port #{port}:" > t =3D TCPSocket.new( host.port ) > puts t.gets > t.close > rescue SystemCallError > puts "Unable to gonnect to port #{port}: #$!" > end > end That did the trick, thank you. Also thanks for for showing how to interpolate variables inside a string. I will get this with time... Thanks again, =2Dd =2D-=20 darren kirby :: Part of the problem since 1976 :: http://badcomputer.org "...the number of UNIX installations has grown to 10, with more expected..." =2D Dennis Ritchie and Ken Thompson, June 1972 --nextPart1303285.D6Kjd1O4IS Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQBEgKgiwPD5Cr/3CJgRArKJAJ9WXyVAWVaAyxPmPGWU7KJR74pG+wCfVlmD s1NCLcg5qVRN4q8IB6UuRXg= =YRoa -----END PGP SIGNATURE----- --nextPart1303285.D6Kjd1O4IS--