Jump to content

getting output of existing command prompt


Recommended Posts

I've seen a lot of topics about how to get the StdOut/StdIn/StdErr of a child process when run() from autoit. But is there a way to read the console output of a cmd window that already exists?

Basically this is what I am trying to do. There is a dos command that gets run and I do not have easy access to how it gets run. This command calls a series of applications, ant tasks, etc... and I only really care about one specific part. So I want to be able to tell Autoit "Watch this cmd window and when it writes out 'executing <myCode>' send a pause key and pop up a messagebox telling me that it's paused". I haven't found anything that would allow me to do that yet.

Any ideas?

Link to comment
Share on other sites

I've seen a lot of topics about how to get the StdOut/StdIn/StdErr of a child process when run() from autoit. But is there a way to read the console output of a cmd window that already exists?

Basically this is what I am trying to do. There is a dos command that gets run and I do not have easy access to how it gets run. This command calls a series of applications, ant tasks, etc... and I only really care about one specific part. So I want to be able to tell Autoit "Watch this cmd window and when it writes out 'executing <myCode>' send a pause key and pop up a messagebox telling me that it's paused". I haven't found anything that would allow me to do that yet.

Any ideas?

Try this:

#include <Process.au3>

Func DOS_OUT($COMMAND)
_RunDOS($COMMAND & " >" & @TempDir & "\STDOUT.DAT")
$FILE = FileOpen(@TempDir & "\STDOUT.DAT",0)
$STDOUT = FileRead($FILE)
FileClose($FILE)
Return $STDOUT
EndFunc

;Example
MsgBox(0,"",DOS_OUT("VER"))

When the words fail... music speaks.

Link to comment
Share on other sites

Try this:

#include <Process.au3>

Func DOS_OUT($COMMAND)
_RunDOS($COMMAND & " >" & @TempDir & "\STDOUT.DAT")
$FILE = FileOpen(@TempDir & "\STDOUT.DAT",0)
$STDOUT = FileRead($FILE)
FileClose($FILE)
Return $STDOUT
EndFunc

;Example
MsgBox(0,"",DOS_OUT("VER"))
I don't think this will work. I want it to monitor the output of the dos box live so that when it sees certain text is sends the pause key so that the script execution pauses. Doing it the way you suggest would merely run the entire thing, write it to a file, and then show me the whole thing. This is not live.

Thanks for trying though.

Edit: also, the command is already being executed. For all intents and purposes, assume that this dos box never closes and is just constantly streaming output.

Edited by Traddles
Link to comment
Share on other sites

Thanks for the suggestion Hubertus but I will be doing other things while this is happening and seeing the !{SPACE} menu being navigated over and over would really get in the way. Larry, in order to view "solutions" on that website I need to be a member but I'm not. Can you summarize what the solution was? Or even just a copy/paste would be helpfull. Thanks.

Link to comment
Share on other sites

Thanks for the suggestion Hubertus but I will be doing other things while this is happening and seeing the !{SPACE} menu being navigated over and over would really get in the way. Larry, in order to view "solutions" on that website I need to be a member but I'm not. Can you summarize what the solution was? Or even just a copy/paste would be helpfull. Thanks.

Go to the link and scroll to the bottom of the page... the answers are WAYYY towards the bottom.

Lar.

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Link to comment
Share on other sites

Go to the link and scroll to the bottom of the page... the answers are WAYYY towards the bottom.

Lar.

Don't want to hijack this (just a minor Shanghai), but I find these sites that hide user supplied solutions irritating.

For this and a few other sites, I keep this handy Firefox Bookmarklet on my Toolbar (I call it ZSS for Zap StyleSheet):

java script:(function(){var%20i,x;for(i=0;x=document.styleSheets[i];++i)x.disabled=true;})();
Link to comment
Share on other sites

  • 7 months later...

Go to the link and scroll to the bottom of the page... the answers are WAYYY towards the bottom.

Lar.

I'm getting a 404 error when trying to access the link. Since it's been a while, can you update the thread with a new link, or provide a solution to the problem? I, too, need to capture text from an existing command window that is spawned by another windows app. This dos popup window does some processing of its own before asking user input, so I basically need to determine when the dos popup is ready for input.

I'm still making my way through the forums but so far haven't found a workable solution. Any help would be greatly appreciated.

Thanks,

Danny

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
 Share

  • Recently Browsing   0 members

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