Trying to use CMD to print the output of an executable to a file. The name of the program is adb (in my path). When called without arguments it prints the help text. I can't seem to capture it.

adb > adb.txt - Doesn't work, get an empty txt file
dir > adb.txt - Works fine

I'm probably not seeing something obvious.

  • so adb>a still dumps the output of adb, you want adb 2>a – barlop Jan 29 '16 at 11:10
  • notice that dir sfdsff so as to give a file not found, will need 2>a too. – barlop Jan 29 '16 at 11:11
  • @barlop thanks, maybe I'll see if I can tweak my console to change colors depending on stderr or stdout :) – jiggunjer Jan 29 '16 at 11:32
  • I can't imagine any option within cmd itself. There is a color command but to link it to stdout and stderr, I doubt.. so maybe nextofwindows.com/… though even there I doubt it, though I haven't really used the alternatives much, but it'd be a damn good feature if it was there. – barlop Jan 29 '16 at 12:06
  • @barlop actually I'm using conemu64. Doesn't feel as fast sometimes, but supports full screen and normal copy pasting. Lots of options I still need to browse. – jiggunjer Jan 29 '16 at 12:16

This is not a fault with piping (This is actually redirection, piping uses the output in the command of another program, using the | operator), but how adb has implemented output to the cmd prompt. Instead of outputting to STDOUT, it outputs this text to STDERR.

Try this command instead:

adb 2>adb.txt

More information here

  • thanks, odd that it uses stderr for those kind of messages. – jiggunjer Jan 29 '16 at 11:29
  • @jiggunjer Sort of, except it actually is an error message as you've called it without parameters, just not a very concise one ;) – Jonno Jan 29 '16 at 11:29
  • Actually it does the same with adb -h, which is the help switch. – jiggunjer Jan 29 '16 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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