Jump to content

EnvSet("TELNET_REDIR", "1")


jtUSB
 Share

Recommended Posts

I am working on a telnet script and was having problems until I added this line of code (based on some examples I saw here). Can someone help me understand what this line actually does? The help file isn't too helpful with this command...

Link to comment
Share on other sites

Also after I transmit my password, I get a bunch of garble on the console... Does anyone have any idea why? This is the same code others have used for console telnet.

telnet>open xxxxxxxxxxx

Looking up host: xxxxxxxxxxx...

Trying 10.161.177.9:23...

Connected to xxxxxxxxxxx. Escape key is ALT-].

Welcome to Microsoft Telnet Service

login: xxxxxyyyyyyyy

password: [1;1H*[2;1HW[3;1H*[4;1HT[5;1HC[6;1H[K[7;1H[K[8;1H[K[9;1H[K[10;1H[K[11;1H[K[12;1H[K[13;1H[K[14;1H[K[15;1H[K[16;1H[K[17;1H[K[18;1H[K[19;1H[K[20;1H[K[21;1H[K[22;1H[K[23;1H[K[24;1H[K[25;1H[K[5;19H> <----garble I'm talking about

Here is the code:

; Script Start
Dim $ourTelnet, $ourRead, $totalRead = ""
EnvSet("TELNET_REDIR", "1")
$ourTelnet = Run("c:program filestelnettelnet.exe","", @SW_HIDE, 3)
$ourRead = StdoutRead($ourTelnet)
StdinWrite($ourTelnet, "open xxxxxxxxx" & @CR)
Sleep(500)
While 1
    $ourRead = StdoutRead($ourTelnet)
    consolewrite($ourRead);what the server replies
     ;msgbox(0,"LINE 12","wait")
    If StringInStr($ourRead, "login:") > 0 Then
        StdinWrite($ourTelnet, "xxxxxxxyyyyy" & @CR)
        msgbox(0,"test1","")
    ElseIf StringInStr($ourRead, "password:") > 0 Then
        StdinWrite($ourTelnet, "***********" & @CRLF)
        msgbox(0,"test2","")   
    ElseIf StringInStr($ourRead, "#") > 0 Then
        msgbox(0,"test3","")
    ElseIf StringInStr($ourRead, "Connection Terminated") > 0 Then
        Run("notepad.exe")
        WinWait("Untitled")
        WinActivate("Untitled")
        send($totalRead)
        msgbox(4096, "Exit", "A log has been formed")
        ExitLoop
    ElseIf @error Then
        ExitLoop
    Else
        msgbox(0,"test4","")
        ContinueLoop
    EndIf
    $totalRead &= $ourRead
WEnd
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...