views:

578

answers:

4

I am trying to copy a file from my remote server to my local. Here's my script to run it, by using 'expect' to automaticlally send in password

scp user@host:/folder/myFile ./
expect "Password: "
send "myPassword"

When I run this, it still prompts for "Password", what is wrong?

+3  A: 

From what you are trying to do it sounds like you might be better off using ssh with a public and private key. You could google for ssh-keygen tutorial to get started.

Sam
+4  A: 

please do not even leave such scripts around that will be picked up by someone else and used elsewhere.... do try public key authentication, it is are very easy to setup.

nik
+3  A: 

While I agree with Sam and nik, the answer to you questions is that you didn't "hit enter":

send "mypassword\r"
glenn jackman
A: 

Also, you must spawn before

Olivier
spawn: not foundI tried the following command to install spawn, but it still does not work.sudo aptitude install spawn
shantanuo