I am trying to implement a post-commit hook on svn which will scp some files from the svn machine to some other backup machine after each commit. I have written the script with expect as follows
spawn /usr/bin/scp -r $l_dir $r_usr@$r_host:/$r_dir
expect {
timeout { send_user "Timeout"; exit 1 }
eof { send_user "\nConnect failed for $r_host at \n"; exit 1 }
-re ".*es..o.*" {
send_user "sending yes\n"
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
send_user "sending password\n"
exp_send "$r_pwd\r"
}
}
interact
This script is called from the post-commit (bash script) with all the required variables supplied.
The issue is that the when I execute the post-commit hook as
./post-commit
then the scp is succesful. but when it is triggered from an actual commit then the login andn supplying password is successful but the files are not copied
The script with debug output shows (when runnig from the commit trigger)
sending password
send: sending "vashishth\r" to { exp3 }
interact: received eof from spawn_id exp0
Using RSA keys is not possible so I have to use the scp with password. Any help would be highly appreciated.
scp
can't use keys, it actually can - but I wasn't sure from your question if you thought that was possible or not. – cutrightjm Dec 24 '15 at 7:06