Capture output from command line program 
Author Message
 Capture output from command line program

Is there any way to capture the output from a command line program?

I'd like to do something like retText = wshShell.run("ping xyz.com"), with
the output of the job returned, not the return code.

My program is currently redirecting the output to a text file, and then
reading the text file. Is there a better way?



Sun, 07 Sep 2003 02:12:56 GMT  
 Capture output from command line program
the way I do this is retVal = wshShell.run("cmd.exe /c ""ping xyz.com >
c:\file.txt""")
Then you would read the file.txt.



Quote:
> Is there any way to capture the output from a command line program?

> I'd like to do something like retText = wshShell.run("ping xyz.com"), with
> the output of the job returned, not the return code.

> My program is currently redirecting the output to a text file, and then
> reading the text file. Is there a better way?



Mon, 08 Sep 2003 00:21:19 GMT  
 Capture output from command line program
Thanks for the tip. That's exactly what I am doing now. I was hoping there
was a way to avoid creating a text file.

BTW... Do you know if it's possible to do this on a web page? This is for an
intranet, so security isn't a problem.


Quote:
> the way I do this is retVal = wshShell.run("cmd.exe /c ""ping xyz.com >
> c:\file.txt""")
> Then you would read the file.txt.



> > Is there any way to capture the output from a command line program?

> > I'd like to do something like retText = wshShell.run("ping xyz.com"),
with
> > the output of the job returned, not the return code.

> > My program is currently redirecting the output to a text file, and then
> > reading the text file. Is there a better way?



Mon, 08 Sep 2003 01:01:24 GMT  
 Capture output from command line program

Quote:

> BTW... Do you know if it's possible to do this on a web page? This is for an
> intranet, so security isn't a problem.

In the end, anything is *possible* from client side HTML script, but security is *always* a problem.

You can use any COM object inside IE hosted script provided you want to deal with the hassles of the
IE enforced security model regarding "unsafe ActiveX...". Whether the user allows this is strictly
up to them. There is no way to do this silently without some prior acknowledgement and permission
from the end user.  Even the lowest "canned" security settings prompt for use of unsafe components.

Or you can simply use HTAs instead - as simple as saving the file with .hta instead of .htm as the
extension. .hta files are hosted by mshta.exe rather than iexplore.exe, and have a security model
comparable to a conventional Windows desktop application. Of course accepting and executing an HTA
is also up to the end user...

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--



Mon, 08 Sep 2003 02:29:59 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Capture output from command line program

2. Capturing command-line output

3. Capturing command line output

4. command line output - capturing

5. Capturing the output of a command-line tool

6. How to output error from command line program

7. How to output error from command line program

8. Obtaining output from command line program

9. Capture Dos DIR command outputs for VB

10. Capturing Output from shell command to VB

11. Capturing DOS Command Output in VB5

12. Capture all shell command output?

 

 
Powered by phpBB® Forum Software