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
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Sai
  • 31

1 Answers1

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"
[...]
Mathieu
  • 2,719