Jump to content

Issue with reading the output from telnet


Recommended Posts

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)
Link to comment
Share on other sites

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.

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