Need to quit out of for loop.

Hi,

Here is my code to send read.txt to three servers.

col="prd167.mybank.com prd168.mybank.com bsprd169.mybank.com"
set -A look $col
for IndixList in ${look[@]};
do
scp /tmp/read.txt admin@$IndixList:/tmp
done

This works and all the 3 servers gets the read.txt file.

However, after the thrid server's scp command is procesed it asks for the password. We login with user1 / password and then switch to admin user using the command sudo su - admin which does not ask for any password nor do we know off any password for admin user.

My job's done !! but i wish to somehow come out of the for loop so the rest of the unix script gets executed.

Your issue is not with the bit of code you submitted, but elsewhere in your script so we cant help you...

Have a look at ~/.netrc.
Either you miss the 'credentials' (uid/pw) of the 3rd server there, or have supplied them elsewhere for the first 2 servers.

Hope this helps

It has to do with the for loop scp cmd where it prompts for the password.

See the snapshot, it shows where it freezes and waits for the password when the file is already transfered.

http://i.cubeupload.com/rsS0XW.png

So post #3 gives you the answer...
You need to do the same as what was done for the 2 other servers... ( public key exchange seems...)

The keys cannot be set due to policies in place. The configuration is exactly the same on all three servers. If it was the issue with the third and last server, then I reduced the server list to only two.

Now it is asking password for the second server !!

Let me tell you the read.txt file does get copied to all the servers. All i wish is to get rid of the final server (whichever it be) password prompt and somehow exit the forloop for the remaining script to be executed.

A bit hard to believe. And, btw, 'twas readdate.txt in your screenshot. Please post a log of the entire session. Are you sure there's no <carriage return> char in there somewhere?

Remove the for loop entirely then rerun it. Or put an echo for loop is done after the for loop. I think you are exiting your for loop. Then later on you have something else that causes the password prompt.

I have a few echo commands just after the for loop completes.

So, if i were comming out of the for loop i should have seen the echo output which i see not.

I echo the scp command and nothing changes but the server names, so the scp command is fine. I am not feeding in the pswd as i see that the file gets copied without the need of the password nor do i know the password for admin user.

Can we somehow not feed in the password for scp for the last server whichever it may be; and let the control for the rest of the script code ? Any work around even if unconventional will do !!