actually, it does work.. it is just when putting in a for loop then it starts asking for password again.

pass=$1
for i in $(cat file)
do
echo "$pass" | scp --stdin source destination
done

uh.. sorry for the confusion but i just figured that if the code is exectued outside the script it works fine.

putting the same code in a script it will prompt for password. scratching my head now.

Hi k2k!

Were you able to figure this out? Personally I've found that using keys for authentication is much more reliable (and possibly more secure?) than using passwords in scripting tasks like this. Is that an option in your case?

Gromit,
Thanks for your reply but yea, you were absolutely right. I resolved it by using RSA. I actually had done it before, it is just I haven't used linux for a while and I had to kinda learn things again. = )
Thanks and I am all set.

This question has already been answered. Start a new discussion instead.