views:

40

answers:

3

I have a small command line tool and after running it, I'd like to display the text output in a way that's easy for someone to copy/paste and save it or email it to someone else.

Copy/pasting from a command prompt is not done in the standard way, so I don't want people to have to copy/paste from there. Saving the file to disk is possible, but the folder where the tool is located may not have access rights so the user would have to configure the output file location (this may be too tricky for some users).

I was thinking of launching notepad with some text in it, generated from the command line tool. Is this possible? Any other suggestions?

+2  A: 

You can use clip.

After you have clip, which can be downloaded from the link above, you use the pipe (|) command to copy the previously executed command's output to the clipboard.

The article gives you the full explanation, but here are the basics with examples:

dir /h | clip – Copy the help manual for DIR command to the clipboard

tracert www.labnol.org | clip – Trace the path from your computer to another website – the output is automatically copied to the clipboard and not displayed on the screen.

netstat | clip - Check if your computer is connecting to websites without your knowledge.

Sev
I was going to recommend this.
Preet Sangha
Thanks... Never knew this tool existed before.
Martin
A: 

I think your command sould receive the destination e-mail as a parameter and then after executing, your command you can have simple script/.BAT file which e-mails your text output to the user using the standard Telnet SMTP commands, like explained for example in the following page:

Ricardo
A: 

You could add an option to your program that tells it to copy its own output to the clipboard using the clipboard API. Then the user could just paste it.

I like the clip suggestion, though.

Adrian McCarthy