How does one create a script that responds to console output? For instance, I'm trying to setup a cron that periodically svnsync 's changes to my repository to a backup server every midnight. The problem is, in order to sync, it prompts for authorization credentials.

svnsync sync accepts no options to specify a login thus a simple cron command is out. I believe I can launch a script but I'm trying to figure out how to make it respond to console output.

4 Answers
4

I was in doubt when you said "svnsync sync accepts no options to specify a login" so I checked the documentation and guess what, it does:

--source-password
--source-username
--sync-password
--sync-username

Those options should be enough for you to go back to a simple cron script.

Back into the case where you really can't specify such options, it is still easy to write a wrapper script that sends data to the program's stdin. For example the following may work (where program is the program you wan to run, and text is a file where you store text to be sent to the program):

program < text

However, for authentication, programs are often written to ready from tty and not from stdin (for security reasons). I'm not familiar with it, but you can still create a fake terminal in that case. This is where expect comes into use.

I thought those options were specific to an option other than sync, I suppose I read wrong. Thank you clarifying my misconception and answering my misinformed question simultaneously.
–
KenFeb 10 '11 at 0:36