Jump to content

Need a few simple telnet commands executed


Recommended Posts

I'm looking to automate a few telnet commands via a GUI. It needs to have the ability to input the IP address then launch the telnet session executing commands based on what has been specified in the GUI. I'm a complete newbie at anything related to programing. I'm a wireless internet engineer : ( This is needed to enable/disable the ethernet port on a device.

post-44015-1236369426_thumb.jpg

The Telnet code looks like this:

telnet 192.168.40.101

Login: admin

Password: *from gui*

set DataTraffic *from gui* Note: (1 = enabled & 0 = disabled)

logout

y

exit

Any help is greatly appreciated.

Link to comment
Share on other sites

Here's what I have so far...it works up to the point where it needs to include the IP address but nothing shows up. Obviously, this code was taken from the help, but I may have butchered it.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $IP, $n2, $msg
    
    GUICreate("My GUICtrlRead")
    
    $IP = GUICtrlCreateInput("", 10, 10, -1, 20)
    
    $n2 = GUICtrlCreateButton("OK", 10, 30, 50)
    GUICtrlSetState(-1, $GUI_FOCUS)
    
    GUISetState()
    
    Do
        $msg = GUIGetMsg()
        If $msg = $n2 Then

        Run("cmd.exe")
        WinWaitActive("C:\WINDOWS\system32\cmd.exe")
        Send("telnet ", GUICtrlRead($IP))

        EndIf
    Until $msg = $GUI_EVENT_CLOSE
EndFunc
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...