Jump to content

How to get the input from CMD


Recommended Posts

Hi Friends..

Is there any way to get the input from command prompt

if i send abcd and enter the CMD will say

'abcd' is not recognized as an internal or external command,

operable program or batch file.

i want put this in a message box ..

is there any commond i can use to get the input from CMD

Thanks and Regards

Sumanth

Link to comment
Share on other sites

In my program there resides this piece:

Local $console = Run(@ComSpec & " /c ping -n 1 -w " & $timeout & " -l " & $icmpsize & " " & $active[$j], @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; Run a command screen with a ping command
    
    While 1
        $line = StdoutRead($console) ; Read a line of the output of the command screen output
        If @error Then ExitLoop
        $selectedoutput &= $line ; Put all the read lines together in one variable
    WEnd

(Thanks to: GaryFrost)

You can see there that a ping command (with variables) is given to a cmd.

In the while loop thereafter the lines from the output are gathered.

You'll have to dissassamble this piece yourself :)

Ofcourse if you can't see the trees through the forrest post ur question(s) here.

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

Read the help file... Look up "Run" and the Std* functions.

eg:

#include <Constants.au3>
$foo = Run(@ComSpec & " /c abcd","","",$STDERR_CHILD)

While 1
    $line = StderrRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend
Thanks for your comment...

i think it works only with CMD if i telnet from cmd it still calls cmd only

if i send "useradd root" it excutes this line in CMD and gives the output

i have not understud what is @ComSpec command

i have read the help file but not able to understand ...

is there any for this problem

Thanks n Regards

sumanth

Link to comment
Share on other sites

@ComSpec is the same as the Environment variable of your computer to the cmd.exe

(Mine points to: %SystemRoot%\system32\cmd.exe)

So instead of using the full path u can use @ComSpec.

U probably want to use something to:

#include <Constants.au3>
$foo = Run(@ComSpec & " /k telnet 1.2.3.4 23","","",$STDERR_CHILD) ; 1.2.3.4 = IPaddress and 23 = portnumber /k lets the cmd remain active and /c shuts down the cmd after the command has run

The only thing is that I don't know how to create a DOS window, let it remain and send commands to it afterwards.

So the code here isn't working as you want!

What this does is creating a dosbox, send a telnet command to it and let the box stay open. And ofc records output in $foo

P.S. The FAQ in the help file contains some information about this.

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

@ComSpec is the same as the Environment variable of your computer to the cmd.exe

(Mine points to: %SystemRoot%\system32\cmd.exe)

So instead of using the full path u can use @ComSpec.

U probably want to use something to:

#include <Constants.au3>
$foo = Run(@ComSpec & " /k telnet 1.2.3.4 23","","",$STDERR_CHILD) ; 1.2.3.4 = IPaddress and 23 = portnumber /k lets the cmd remain active and /c shuts down the cmd after the command has run

The only thing is that I don't know how to create a DOS window, let it remain and send commands to it afterwards.

So the code here isn't working as you want!

What this does is creating a dosbox, send a telnet command to it and let the box stay open. And ofc records output in $foo

P.S. The FAQ in the help file contains some information about this.

Thanks a Lot My friend..

I will try the same...

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