Sign in to follow this  
Followers 0
madmatrix

Issue with reading the output from telnet

3 posts in this topic

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)

Share this post


Link to post
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)

When the words fail... music speaks

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0