3

I run the following at regular intervals in order to sync my laptop with my desktop. When there's nothing to do, and therefore no output from unison, i want it to complete silently; when there's syncing to be done, t want it to pop up in a terminal so I can accept or reject changes as required.

Currently, it always pops up a window regardless and i'm harassed by occasional blank terminals appearing and disappearing. Here's the command that I run automatically every 30 minutes or so:

ps -e | grep -i unison || xterm -e 'unison -auto -perms=0 -terse Local_Sync'

Can anyone think of a better way to accomplish this?

2
  • I'm not familiar with unison, but -auto means "automatically accept default actions" (according to the man page). What is there to accept or reject? If no user interaction is required, don't run it in xterm and it won't open a terminal. You may be interested in the -batch option, too.
    – Roger Pate
    Aug 23, 2010 at 5:10
  • Indeed it does. If I had absolute trust in file syncing then I'd use auto and never have to pop up anything! Unfortunately I'm just a bit paranoid that one morning I'll wake to find that an empty directory has been 'auto' sync'd over all my other copies, as I use the syncing as a way of keeping backups too and like to confirm what unison will do. I might go this way eventually though as I can't find a dry-run option in unison (though rsync has one). Thanks for your suggestions.
    – themuddler
    Aug 26, 2010 at 19:22

2 Answers 2

3

You'd probably have to draw it out into a script where you could pipe the output to a variable, check if there's anything in that var and then echo it in an xterm if it has content.

1
  • Here's the output I'm talking about: "local mud-desktop deleted ----> test Proceed with propagating updates? []" So I could pipe it to a variable and test that, then echo it. The problem is that it wants input from me as well and just echoing its output won't allow that I don't think. Perhaps I could run it in a 'simulate' mode and test for output, and if there is some, run it again properly. That would lead to two update checks but only on the occasions that there's an update to be done. Can't find a 'sim' mode in the docs though. Any ideas?
    – themuddler
    Aug 24, 2010 at 19:14
1

I agree with Oli, it would be much easier to do in a script which you can make a cron job to run every 30 minutes see

man crontab
1
  • Thanks, using a cron job already to run it as a one-line 'script' but there's nothing intelligent in there yet. I need to figure out how to get unison to do a 'dry-run'. Time to read the man pages again!
    – themuddler
    Aug 24, 2010 at 19:17

Not the answer you're looking for? Browse other questions tagged .