Jump to content

How to grab text from a MS-DOS shell


atts
 Share

Recommended Posts

All,

Anyone know how I can grab text in a MS-DOS shell.

Here's what I have and what i'm trying to do.

I have a utility which runs from a MS-DOS shell, the utility then has its own

shell like environment - in which I can enter commands and get a response

back.

So, I'm trying to automate the testing, by issuing the commands -- which is

the easy bit. The problem I'm having is grabbing the responses to the

commands being issued.

Any hints/pointers would be appreciated, or even better if anyone has an

example would be greatly appreciated.

thanks.

atts

Link to comment
Share on other sites

I cannot exactly understand your problem. Does your program deliver a GUI or a DOS issue as for example the dir command? Do you have a screenshot?

With 'WinGetText()' you can retrieve text from a window.

With 'StdoutRead' you can read in a number of characters from the STDOUT stream of a previously run child process.

#include <Constants.au3>
Dim $text
$stream = Run(@comspec & ' /c net use','',@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $textline = StdoutRead($stream)
    $text = $text & @CRLF & $textline
    If @error Then ExitLoop    
Wend

MsgBox(0, "STDOUT read:", $text)

I hope this helps you a little bit.

Edited by Briegel
Link to comment
Share on other sites

I cannot exactly understand your problem. Does your program deliver a GUI or a DOS issue as for example the dir command? Do you have a screenshot?

With 'WinGetText()' you can retrieve text from a window.

With 'StdoutRead' you can read in a number of characters from the STDOUT stream of a previously run child process.

#include <Constants.au3>
Dim $text
$stream = Run(@comspec & ' /c net use','',@SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
    $textline = StdoutRead($stream)
    $text = $text & @CRLF & $textline
    If @error Then ExitLoop    
Wend

MsgBox(0, "STDOUT read:", $text)

I hope this helps you a little bit.

Hi,

I've attached a screen dump to help explain. The utility under test is launched from the MS-DOS

shell prompt. The utility then runs with its own shell - i.e. the red text "oxshell>"

So the two commands entered - "help" and "version" results in the help screen and version number

of the utility (not for the dos shell).

I already have a AutoIt script which will launch a MS-DOS window, starts the utility and then issue

commands. But I can't do anything more intelligent with it.

Say for example, when I issue the "version" command how do i grab the output - like the number "1.0003"

the version number of exe, you'll have to see the attached picture.

I've looked at AutoIt's "Window Info program", this does not show any text within the "Visible Window Text"

thus I don't believe you can use the function WinGetText.

You mention StdoutRead? I searched this function in the help - but it's not listed? I'm using v3.

thanks.

Link to comment
Share on other sites

Hi,

I've attached a screen dump to help explain. The utility under test is launched from the MS-DOS

shell prompt. The utility then runs with its own shell - i.e. the red text "oxshell>"

In all likeliehood you are going to need to be able to copy text to the clipboard.

Depending on your control of the boxes you run testing from, you can use the mouse movements or the send() functions to control the keyboard -- you can drag over the window, get the text to the clipboard, then parse the text from there using ClipGet()

You will definitely want the "QuickEdit" options enabled in your command shell.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

  • Moderators

You need to download Beta to get the extra functions that are being used to work and for the information on them in the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...