Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a daily scheduled .bat batch script that runs Fossil, and automatically commits that day's changes to my projects' source tree. Now I've set it to run every day, including the weekends, since I also want it to pick up changes that I do when working on weekends.

Usually, though, I won't be working on weekends, and so it doesn't need to commit anything for that day (since there are effectively no changes).

Now fossil has the changes command, which can tell me beforehand what changes there are. Unfortunately, it doesn't appear to set the errorlevel. It just doesn't print anything to the output stream (or perhaps a single CRLF) if there is no change.

My question: is there a way to detect the presence of output from a batch file, so I can still use the changes command to detect whether to perform a commit or not?

share|improve this question
up vote 3 down vote accepted

You can try using for /f statement. The syntax would be something like this:

for /f %%i in ('fossil_command_goes_here') do

Next, test %i for content and process if not empty

share|improve this answer
Thank you, I didn't know the for /f syntax for executing commands. So if I just want to perform the commit once, I can do that, then goto End, I take it? – Martijn May 31 '11 at 14:39
correct. More accurately 'goto :EOF' as :EOF is defined by default for all scripts. – uSlackr May 31 '11 at 15:53
I bow to you sir: I didn’t know about :EOF either — pity I can’t upvote twice... :-) – Martijn Jun 1 '11 at 7:18
LOL. It only means I've written too much in the old language. Go Powershell! – uSlackr Sep 14 '11 at 21:02

You must log in to answer this question.

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