Jump to content

Output command prompt's command to a text file gives a blank file


kumarkumar

Recommended Posts

I have some help commands pertaining to some program which I wish to save in a txt file. Unfortunately all it gives is a blank file.

I have used the normal command "command help > somefile.txt". As I understand, using the ">" operator, the output is not dumped to the command prompt window but to the text file. But in this case running this command the output is dumped to the command prompt window as well giving a blank text file.

It works with regular DOS commands like "dir > somefile.txt" but not with the specific command that I have.

I also tried with clip.exe. Same problem with this too.

I could do it with mark & paste but that's not what I am looking for.

Link to comment
Share on other sites


Assuming "help" is a text file as described above, try the following in a CMD window:

TYPE help >somefile.txt

Edited by 5eraph
Link to comment
Share on other sites

I have some help commands pertaining to some program which I wish to save in a txt file. Unfortunately all it gives is a blank file.

I have used the normal command "command help > somefile.txt". As I understand, using the ">" operator, the output is not dumped to the command prompt window but to the text file. But in this case running this command the output is dumped to the command prompt window as well giving a blank text file.

It works with regular DOS commands like "dir > somefile.txt" but not with the specific command that I have.

I also tried with clip.exe. Same problem with this too.

I could do it with mark & paste but that's not what I am looking for.

The redirection can be from BOTH "standard output" and from "standard error" see here:

http://www.robvanderwoude.com/redirection.php

Some programs may send the output of the "help" parameter to the "standard error".

You have no way to know as they appear in the console exactly as "standard output" does.

Try:

command help > somefile.txt 2>&1

Next time, please avoid "vague" descriptions, like "some help commands", "pertaining to some program", and the like,. STATE the EXACT program and the EXACT command and parameter you attempted issuing, as it is more likely that you won't be misunderstood and possibly have a more "targeted" reply.

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

I have used this operator without error before. Make sure you are specifying a path for the file. Just specifying the file name itself means Windows will save it somewhere. Do you know where that place is? Are you not sure the file you are looking at is in-fact the one that was just written?

Link to comment
Share on other sites

The redirection can be from BOTH "standard output" and from "standard error" see here:

http://www.robvanderwoude.com/redirection.php

Some programs may send the output of the "help" parameter to the "standard error".

You have no way to know as they appear in the console exactly as "standard output" does.

Try:

command help > somefile.txt 2>&1

Thanks a lot jalaz. That worked like a charm. It turns out it was from "standard error", hence

command 2> file

worked too.

Next time, please avoid "vague" descriptions, like "some help commands", "pertaining to some program", and the like,. STATE the EXACT program and the EXACT command and parameter you attempted issuing, as it is more likely that you won't be misunderstood and possibly have a more "targeted" reply.

jaclaz

With due respect......

My "vague" descriptions of commands & programs were intentional.

The program I am talking about is "devtest", and the command was "devtest help > devtest_help.txt". I wanted the output of "devtest help" to a text file.

Since the outside world is mostly unaware of the program how would it have made any difference to the readers if I had mentioned anything in place of "devtest". Since regular DOS commands are mostly known to everyone hence in this case I did mention the exact command "dir > somefile.txt" so that others may get what I am trying to convey.

Let me know if in this case mentioning the exact program and exact command would have helped in any way. If so I will take care henceforth to mention the exact program/commands.

Link to comment
Share on other sites

With due respect......

My "vague" descriptions of commands & programs were intentional.

The program I am talking about is "devtest", and the command was "devtest help > devtest_help.txt". I wanted the output of "devtest help" to a text file.

Since the outside world is mostly unaware of the program how would it have made any difference to the readers if I had mentioned anything in place of "devtest". Since regular DOS commands are mostly known to everyone hence in this case I did mention the exact command "dir > somefile.txt" so that others may get what I am trying to convey.

Let me know if in this case mentioning the exact program and exact command would have helped in any way. If so I will take care henceforth to mention the exact program/commands.

Well, clearly 5eraph - usually attentive and knowledgeable - did misunderstand you, and I had the same problem initially.

Most "normal" command line programs do output the result of command to "standard output" and not to "standard error" AND normally use a parameter with a prepended slash or dash, it was NOT immediate to understand the question.

On the other hand for all we knew, it could have been another kind of command, as an example you can take DISKPART or WMIC, that do behave "differently" from standard commands (and use not the slash or dash for parameters).

Giving the exact reference - and when available - a link to the homesite of the program besides would have made your problem (and hopefully it's answer) findable by other members (or "passers-by") having your same problem.

I mean, if you have a problem with, say, devtest, do you google for "devtest help" or for "some program some help commands"? :w00t:

This is one of the advantages of a board (as opposed to PM's or e-mail or phone help/support) problems (and hopefully solutions) are public and may be of use to a lot more people than OP. ;)

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

I mean, if you have a problem with, say, devtest, do you google for "devtest help" or for "some program some help commands"? :w00t:

Got the message.

Most "normal" command line programs do output the result of command to "standard output" and not to "standard error" AND normally use a parameter with a prepended slash or dash, it was NOT immediate to understand the question.

On the other hand for all we knew, it could have been another kind of command, as an example you can take DISKPART or WMIC, that do behave "differently" from standard commands (and use not the slash or dash for parameters).

As per the official help of "devtest", help is invoked on using "devtest help". However I found all the commands below to invoke help.

"devtest help"

"devtest -help"

"devtest -h"

All of them redirect to "standard error".

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...