You only get the first host from the dnsServers line because that's what you asked for! The regular expression '/dnsServers=(\S+)/' is only looking for the first sequence of non-whitespace characters from the line. Better would be:

The commas are there; the split() should have worked. To debug, add more debug print statements (one that prints each server as it is parsed from the line would be good). Or you could use the perl debugger (try "perldoc perldebug" from the command line) and step through the code.

Really? Are you sure it's dying or is it just finishing the server list w/o doing anything? If it's really dying, that could be because one of the $ssh methods is throwing an exception. To make sure this isn't the case, try enclosing the login in an eval block:

Hi Larry, I am sure it fails since I tried to manully SSH. Looks like some servers my password/token does not work. So if you could please add the code where it will skip the ones that I cant ssh to as well as perhaps log that server that failed so I know that it needs special attention.

We've already wrapped the login with eval. If the login fails, the program executes 'next;' which should take you to the next loop iteration (i.e., next dns server), NOT exit.

Here is your next assignment: Start putting in diagnostic print statements (e.g. "Got here: 1", "Got here: 2", etc.) until you find out exactly what statement, if any, is causing your program to exit. Make sure you add one at the bottom of the program so you'll know if you get to the end.

Please post your instrumented code as well as the full program output.

Sorry, that's not how we play the game here . I'm not going to write this program for you (much). Besides, I don't have the right dns setup here to run your program.

But don't panic! I'm not asking for the moon. Just put a print statement before and after each call to one of the ssh methods in your program, plus one at the start and end of the program. You can do that, can't you? Then, run the program, and post the code (with the print statements) and the program results.

Hello Larry, sorry for the delay, I was in self pity for a bit but I am back. When I put the ssh login in without eval mode Looks like it works ok, as you can see I don’t have access to several servers on Asia or EMEA. I expected the script to continue like it has been, but as you can see I get a time out

I got lots of updates, and I am sorry if its long.

Non-Eval Mode:

ls-2: found=no

init: found=no

ls-1: found=yes

ls-2: found=yes

Could not login to irprns711b.ny.rich.com

Could not login to proxys77.ny.rich.com

init: found=no

ls-1: found=no

ls-2: found=no

Could not login to gadns01.ct.sg.criche.com

Could not login to gdns03.ct.sg.criche.com

Could not login to xp0124.ssh.hk.sarkie.com

Could not login to hxp0125.ssh.hk.sarkie.com

Could not login to kxp0426.ssh.hk.sarkie.com

Could not login to kkxp6127.sly.hk.sarkie.com

Could not login to srbdns01.ct.sg.criche.com

Could not login to tjp-dns-04.tk.jp.criche.com

Could not login to tlp-dns-05.tk.jp.criche.com

SSHAuthenticationError Login timed out. The input stream currently has the contents bellow: at /usr/lib/perl5/site_perl/5.10/Expect.pm line 828

Could not chdir to home directory /home/richsark: No such file or directory

$ at test3.pl line 43, <$in> line 5.

init: found=no

ls-1: found=yes

ls-2: found=yes

$ssh->login() failed: Login output was

richsark's Password: at test3.pl line 43, <$in> line 70.

The script still continues…..

But.. there are some servers that have a different prompt versus the original we have in place.

some servers when I SSH to have this senerio which I have to type in "yes" to continue:

Could not create directory '/home/richsark.ssh'. The authenticity of host 'sarkie.ky.sarfish.com (19.97.6.15)' can't be established RSA key fingerprint is 96:42:39:ff:a4:3c:1a:17:7d:5b:7e:a4:8a:b7:3d:51. Are you sure you want to continue connecting (yes/no)? yes Failed to add the host to the list of known hosts (/home/richsark/.ssh/known_hosts).

How can we had this to the script to allow such scenario, That may solve some of my login problems, but I think there me another underlying issue under the radar.

Good news! ssh->login() is not throwing an exception. All of the problems are normal login failures to the remote host. That means that the eval {} block around the login isn't necessary (but you still have to process login's output).

Looking at your program's output, I see 3 reasons your logins are failing:

1. "Could not chdir to home directory /home/richsark: No such file or directory" This means that the richsark user doesn't have a home directory setup on that host. Talk to the system administrator and have him or her create one for you.

2. "richsark's Password:" The user/password you used was rejected by the server. Again, talk to the sysadmin for the host and get that fixed. UPDATE: Another possibility is that the remote host requires a carriage return or something before you get to the login prompt.

Both of the above problems are easiest debugged by ssh'ing from the command line (preferably with the remote administrator on the phone!).

The remaining problems are all about a mismatch between what Expect expected to happen during the login session and what really happened. Basically, you are going to have to "expect" the prompt to enter "yes" (or whatever). If you get it, your script will have to send the proper response. RTM for Expect (I'm sure there's an Expect forum somewhere out there, too). I'm no expert.

i try to login to a system that throws me directly to an application and dose not give a prompt. the result is that the login process of ssh::expect dose not finish and just hangs there till i kill the ssh process manually.

It sounds like the standard ssh port (22) on that machine or on the firewall router at the remote site is configured to "tunnel" to a different program other than /bin/login. I'd have to look at their setup to say more. However, for you the solution is simple! Contact the Sysadmin of the remote system and explain your problem. If you have a legitimate need for shell access to their system, the admin will either fix the port configuration or work out a different protocol that gets you in. Otherwise, they'll tell you to take a hike :)