Jump to content

Recommended Posts

Posted

I'm using cmd.exe to telnet some host. And that host will pop up with user name and password. After that, I will match the string to know what I should input. But when I run cmd.exe and send "telnet host", the user and password pompt wasn't captured and the telnet window also was closed. I want the telnet windows stay on. Then I can watch what the script is doing.

Here is my simple start code:

Local $foo = Run(@ComSpec & " /c " & "cmd.exe", @SystemDir, @SW_MAXIMIZE, $STDIN_CHILD + $STDOUT_CHILD)
StdinWrite($foo, "telnet host" & @CRLF)
StdinWrite($foo)

; Read from child's STDOUT and show
Local $data
While True
    $data &= StdoutRead($foo)
    If @error Then ExitLoop
    Sleep(25)
WEnd
MsgBox(0, "Debug", $data)
Posted

Try this:

#include <Process.au3>
_RunDOS("telnet host >" & @TempDir & "\telnet.txt")
$FILE = FileOpen(@TempDir & "\telnet.txt",0)
$OUT = FileRead($FILE)
FileClose($FILE)
MsgBox(0,"OUT",$OUT)
Posted

Try this:

#include <Process.au3>
_RunDOS("telnet host >" & @TempDir & "\telnet.txt")
$FILE = FileOpen(@TempDir & "\telnet.txt",0)
$OUT = FileRead($FILE)
FileClose($FILE)
MsgBox(0,"OUT",$OUT)

Thank you. But I tried and nothing captured. It's weired.

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
×
×
  • Create New...