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