I am trying to design a Backup Manager for myself. I was able to list all the files successfully. Now i want to create a link called Migrate which when clicked executes a Shell commands and migrate the file to another server using SCP. I tried manually running other commands but only SCP was able to transfer the file successfully. But with SCP, we don't have option to enter password.
sshpass also doesn't seems to work.
I also tried the following code by creating text.exe file and running it using expect but thats also dint work:
#!/usr/bin/expect
spawn scp file.zip username@host:destination
set pass "password"
expect {
"*password:*" {send "$pass"; exp_continue}
}
Please provide a solution for this.
Further, I want to send the file.zip using post as the name of the file is defined by phpfunction $file_name.
How do i send $file_name using post or anyother method to this test.exe file? so that the following line looks like:
spawn scp file_name.zip username@host:destination
Thank you!