tags:

views:

65

answers:

2

I am trying to save output of Mercurial commands in a file

hg init > log.txt

but its not working. Any ideas?

+2  A: 

The output might be on standard error.

Try hg init 2>&1 > log.txt.

Borealid
Yup, what he said.
leo grrr
+2  A: 

Are you sure the output is not simply silent by default?

hg init, for instance, rarely (if ever?) actually prints any output. Many Mercurial commands are the same way. You can often specify -v to get more verbose output, but in the case of the example you gave, I would expect an empty log.txt to appear. Have you tried other commands? If so, what exactly is not working? Do you get an empty log.txt or no log.txt at all?

bjlaub
I get an empty file. If hg init throws an error like "repository already exist", I want to check that error in my script. Is that possible ?
Nitesh
Let me elaborate more on this..I am trying to automate hg commands using firefox extension. I am using process.run to execute these commands. Sometimes when you update your repository, you get conflicts error in command prompt. I want to check if there any conflicts exist, give user option to discard or merge.Does that make sense ?
Nitesh
bjlaub
Thanks for the info...Can you store standard output value in a variable in Javascript instead of writing in to a file and then reading it ?
Nitesh