Why not use SSH Certification for this.
My earlier working setup goes as below:
1. The basis of using ssh without typing your password is public key based authentication. You need to generate a pair of public/private keys for this. We shall stick to version 2 of ssh.
2. Firstly, generate your public/private keys using ssh-keygen
% ssh-keygen -t rsa
Must use the -t option to specify that you are producing keys for SSHv2 using RSA. This will generate your id_rsa and id_rsa.pub in the .ssh directory in your home directory. I strongly suggest using a passphrase.
3. Now copy the id_rsa.pub to the .ssh directory of the remote host you want to logon to as authorized_keys2.
[Note: If you have more than one host from which you want to connect to the remote host, you need to add the local host's id_rsa.pub as one line in the authorized_keys2 file of the remote host, i.e., you can have more than one entry. Also, you need to 'chmod 644 authorized_keys2' to make it unwritable to everybody apart from the user. It is best to have .ssh and associated directories on the server machine to have at most 0600 permissions. ]
You are basically telling the sshd daemon on the remote machine to encrypt the connection with this public key and that this key is authorized for version 2 of the ssh protocol.
% scp ~root/.ssh/id_rsa.pub root@server-ip:~root/.ssh/authorized_keys2
After this what you have to do is just create a script with scp commands to transfers files & let us know if still that problem persists.
Thanks goes to author from where I took the above tutorial and all who suggested me to use SSH instead of expect in this forum.