#72128 - 2002-12-08 09:34 AM
Can Kix do this? (Perl\Auto login)
|
attiahia
Hey THIS is FUN
Registered: 2000-03-27
Posts: 268
|
I have about 45 network switches I used to access them manually (Telnet) to extract their active ports and the MAC address for each workstation connected to each port.
When I posted a question About 2 months ago on this board asking about how can I automate the login process to these switches, I received a valuable advice from Lligetfa to use PERL because it has the capability to do such thing.
Unlike SU.exe which used by Kix, I found Perl code does not need any service to be installed on the device which you will connect to it remotely and implement some commands on it.
The following Perl code login to one of these switches and implement the commands (remotely) which I used to implement manually.
use Net::Telnet; my $Telnet = new Net::Telnet; my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/'; $telnet = new Net::Telnet ( Timeout=>20, Prompt => $prmpt, Errmode=>'die'); $telnet->open('XX.XXX.XXX.XXX'); $telnet->login('user Id','Password'); @lines= $telnet->cmd("Networking"); @lines= $telnet->cmd("IP"); @lines= $telnet->cmd("ipmac"); print STDOUT @lines; $telnet->close;
Frankly speaking I have been using Kix for about 3 years and I like it too much and I hope if there is any Kix code or function that can do the same thing for me. Any help will be highly appreciated. Thank you.
Note: I am still facing some problem with the previous Perl code where in some cases give error message “timed-out waiting for command prompt---“ and I am working on solve it.
|
|
Top
|
|
|
|
#72132 - 2002-12-09 11:23 AM
Re: Can Kix do this? (Perl\Auto login)
|
attiahia
Hey THIS is FUN
Registered: 2000-03-27
Posts: 268
|
Gentlemen Thanks a lot for support and please excuse me if I wasn’t clear in what I want.
What I am looking for is some Kix function like: Login ($Server name, $User name, $Password). And then implement any command on that server under the new user name and password.
That is why I mentioned Su.exe because it allows you to switch from user without admin to user with admin privilege and then implement any command under the new account.
Perl\Telnet do the same thing: $telnet->open('XX.XXX.XXX.XXX'); $telnet->login('user Id','Password');
but as I mentioned that I am facing a problem with this code and I hope to replace with any thing from Kix.
Thank you.
|
|
Top
|
|
|
|
#72134 - 2002-12-10 12:35 AM
Re: Can Kix do this? (Perl\Auto login)
|
attiahia
Hey THIS is FUN
Registered: 2000-03-27
Posts: 268
|
Thanks for support. I did not use ftp or web in this, I will explain to you what I used to do manually to get the result what I want.
I access the switch from DOS
D:\>telnet XX.XXX.XXX.XXX “Then I got the following screen” --------------------------------------------- This product includes software developed by the University of California, Berkeley and its contributors.
Welcome to the Alcatel OmniSwitch! Version 4.3.1 GA “then I enter the user id & password” login : user password: user ------------------------------------------------- “If I delay in entering the password I will get the following:” Welcome to the Alcatel OmniSwitch! Version 4.3.1 GA login : user password: login timed out login : ------------------------------------------------- Welcome to the Alcatel OmniSwitch! Version 4.3.1 GA login : user password: user ************************************************** Alcatel OmniSwitch Copyright (c), 1994-2001 Alcatel Internetworking, Incorporated. All rights reserved. OmniSwitch is a trademark of Alcatel Internetworking, Incorporated, registered in the United States Patent and Trademark Office. System Name: BWJ301-R00-01X System Location: BWJ301 Command Main Menu ------------ --------------------------------- File Manage system files Summary: Display summary info for VLANs, bridge, interfaces, etc. VLAN: VLAN management Networking: Configure/view network parameters such as routing, etc. Interface: View or configure the physical interface parameters Security: Configure system security parameters System: View/set system-specific parameters Services: View/set service parameters Switch: Enter Any to Any Switching Menu Help: Help on specific commands Diag: Display diagnostic leve commands Exit/Logout Log out of this session ? Display the current menu contents BWJ301-R00-01X / %
“Then I select networking command” BWJ301-R00-01X / % networking
“And from networking command menu I select ip command”
BWJ301-R00-01X /Networking % ip “And from ip menu I select ipmac command”
BWJ301-R00-01X /Networking/IP % ipmac
“Then I got the result which I want as following:”
IP to MAC ADDRESS ASSOCIATION TABLE
IP Address MAC Address Slot / Intf XX.XXX.XX.X 00C04F:566764 4 / 32 XX.XXX.XX.XX 00C04F:4E2557 4 / 8 XX.XXX.XX.XXX 00C04F:56A2B1 5 / 13 XX.XXX.XX.XXX 00065B:A9ADBE 4 / 16
BWJ301-R00-01X /Networking/IP % exit
Connection to host lost.
Thank you. [ 09. December 2002, 12:40: Message edited by: attiahia ]
|
|
Top
|
|
|
|
#72136 - 2002-12-11 12:04 AM
Re: Can Kix do this? (Perl\Auto login)
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
The simplest way of achieving what you want is to use a telnet package which includes a script language.
There are dozens of commercial offerings, or you could try IVT which is freeware and includes scripting.
You will be able to create a script to log in to each of your switches in turn using send/wait semantics and either record the session to a file, or simulate screen prints to a file.
It also happens to be an excellent vt220 emulator.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1782 anonymous users online.
|
|
|