Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?
Thanks.

share|improve this question

closed as too localized by Luis Alvarado Mar 14 '13 at 17:05

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
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 '10 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 '10 at 19:22
add comment

2 Answers 2

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.

share|improve this answer
    
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 '10 at 19:14
add comment

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
share|improve this answer
    
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 '10 at 19:17
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.