beb7089 Posted March 16, 2007 Posted March 16, 2007 I need to write a script that will telnet into a Cisco router and and perform various commands. This script is for end-users to run on their machine and bring up an encrypted VPN tunnel connection. Telnet is our only option at this point. I can't' for the life of me figure out the best way to retrieve the Gateway (each user has a unique DHCP scope on their router so the gateway addresses are different from person to person). Please help. Thanks beb7089
ptrex Posted March 16, 2007 Posted March 16, 2007 @beb7089 If you run this you will see somewhere a gateway comming up expandcollapse popup#include <date.au3> Dim $strComputer = "." Dim $objWMIService, $colAdapters, $n Dim $utcLeaseObtained, $utcLeaseObtained, $utcLeaseExpired, $strLeaseObtained, $utcLeaseExpires, $strLeaseExpires $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colAdapters = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") $n = 1 For $objAdapter in $colAdapters ConsoleWrite ("Network Adapter " & $n & @CR) ConsoleWrite ("================="& @CR) ConsoleWrite (" Description: " & $objAdapter.Description& @CR) ConsoleWrite (" Physical (MAC) address: " & $objAdapter.MACAddress& @CR) ConsoleWrite (" Host name: " & $objAdapter.DNSHostName& @CR) If Not ($objAdapter.IPAddress) = " " Then For $i = 0 To UBound($objAdapter.IPAddress) ConsoleWrite (" IP address: " & $objAdapter.IPAddress($i)& @CR) Next EndIf If Not ($objAdapter.IPSubnet) = " " Then For $i = 0 To UBound($objAdapter.IPSubnet) ConsoleWrite (" Subnet: " & $objAdapter.IPSubnet($i)& @CR) Next EndIf If Not ($objAdapter.DefaultIPGateway) = " " Then For $i = 0 To UBound($objAdapter.DefaultIPGateway) ConsoleWrite (" Default gateway: " & _ $objAdapter.DefaultIPGateway($i)& @CR) Next EndIf ConsoleWrite (" DNS"& @CR) ConsoleWrite (" ---"& @CR) ConsoleWrite (" DNS servers in search order:"& @CR) If Not ($objAdapter.DNSServerSearchOrder) = " " Then For $i = 0 To UBound($objAdapter.DNSServerSearchOrder) ConsoleWrite (" " & $objAdapter.DNSServerSearchOrder($i)& @CR) Next EndIf ConsoleWrite (" DNS domain: " & $objAdapter.DNSDomain& @CR) If Not ($objAdapter.DNSDomainSuffixSearchOrder) = " " Then For $i = 0 To UBound($objAdapter.DNSDomainSuffixSearchOrder) ConsoleWrite (" DNS suffix search list: " & _ $objAdapter.DNSDomainSuffixSearchOrder($i)& @CR) Next EndIf ConsoleWrite (" DHCP"& @CR) ConsoleWrite (" ----"& @CR) ConsoleWrite (" DHCP enabled: " & $objAdapter.DHCPEnabled& @CR) ConsoleWrite (" DHCP server: " & $objAdapter.DHCPServer& @CR) If Not ($objAdapter.DHCPLeaseObtained) = " " Then $utcLeaseObtained = $objAdapter.DHCPLeaseObtained $strLeaseObtained = WMIDateStringToDate($utcLeaseObtained) Else $strLeaseObtained = "" EndIf ConsoleWrite (" DHCP lease obtained: " & $strLeaseObtained& @CR) If Not ($objAdapter.DHCPLeaseExpires) = " " Then $utcLeaseExpires = $objAdapter.DHCPLeaseExpires $strLeaseExpires = WMIDateStringToDate($utcLeaseExpires) Else $strLeaseExpires = "" EndIf ConsoleWrite (" DHCP lease expires: " & $strLeaseExpires& @CR) ConsoleWrite (" WINS"& @CR) ConsoleWrite (" ----"& @CR) ConsoleWrite (" Primary WINS server: " & $objAdapter.WINSPrimaryServer& @CR) ConsoleWrite (" Secondary WINS server: " & $objAdapter.WINSSecondaryServer& @CR) $n = $n + 1 Next Func WMIDateStringToDate($utcDate) Local $Return $Return = (StringMid($utcDate, 5, 2) & "/" & _ StringMid($utcDate, 7, 2) & "/" & _ StringLeft($utcDate, 4) & " " & _ StringMid ($utcDate, 9, 2) & ":" & _ StringMid($utcDate, 11, 2) & ":" & _ StringMid($utcDate, 13, 2)) Return $Return EndFunc Enjoy !! ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now