0

I have the below line in a script. When I run it, it prompts for a password to copy files in the server. I need the password to be taken from the script.

for i in cat forwarders
do scp -o StrictHostKeyChecking=no $filename $tarfile badgeid@$i:/tmp;
done
1
0

I suggest you to check expect command. A similar situation (with ssh) should look like ...

#!/usr/bin/expect
[...]
spawn ssh [lindex $argv 1]@root@[lindex $argv 0]@x.y.z.j -tt
expect "*?assword" {
   send "$PASSWORD\r"
[...]

Not the answer you're looking for? Browse other questions tagged or ask your own question.