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"
        -re ".*sword.*" {
        send_user "sending password\n"
        exp_send "$r_pwd\r"

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


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.

  • If you're saying 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, 2015 at 7:06
  • I meant that sharing the keys is not allowed for the current svn and backup machine.
    – user39066
    Dec 24, 2015 at 10:06

1 Answer 1


figured out with some google such cases running the expect from cron etc does not wok with interact So I replaced the



expect eof

and the scp is successful

  • Nice work answering your own question! +1 Dec 24, 2015 at 14:01

You must log in to answer this question.