Page 1 of 1 1
Topic Options
#72128 - 2002-12-08 09:34 AM Can Kix do this? (Perl\Auto login)
attiahia Offline
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
#72129 - 2002-12-09 12:42 AM Re: Can Kix do this? (Perl\Auto login)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you shouldn't need su for this job.
anyway, kix has no similar ability to spawn processes.
anyway, if you have wsh (you have if you haven't disabled it) you might use WSHpipe() by chris Steel. [Wink]

what comes to telnet timeout, it could be a matter of re-trial as long as the connection is got.
_________________________
!

download KiXnet

Top
#72130 - 2002-12-08 03:50 PM Re: Can Kix do this? (Perl\Auto login)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
attiahia,
Your comparison of Perl to SU makes no sense. Perl is a programming language whereby SU is service. KiX has nothing built-in to support SU.

The reason I proposed Perl was that KiX does not give you native Telnet-like support as does Perl. There are some add-ons like SocketWrench that through COM can extend KiX if you really want to do this with KiX.

My take on your programming ability is that you adopt as much code as you write so thought you may find some Perl code that, with a bit of modification, would do for you what you need.

If you are accomplished at using COM then take a look at this:

http://www.socket-wrench.com/products/sockettools/socketwrench/index.html
http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=002291
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#72131 - 2002-12-08 03:55 PM Re: Can Kix do this? (Perl\Auto login)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
never got that work though...
_________________________
!

download KiXnet

Top
#72132 - 2002-12-09 11:23 AM Re: Can Kix do this? (Perl\Auto login)
attiahia Offline
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
#72133 - 2002-12-09 11:28 AM Re: Can Kix do this? (Perl\Auto login)
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you say telnet...
can it be done with ftp or web?
or can the access be checked with ip-range instead of user?
_________________________
!

download KiXnet

Top
#72134 - 2002-12-10 12:35 AM Re: Can Kix do this? (Perl\Auto login)
attiahia Offline
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
#72135 - 2002-12-10 12:02 AM Re: Can Kix do this? (Perl\Auto login)
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
attiahia,
I will reiterate. SU is nothing like what you are doing with Telnet. WIth SU, you are impersonating another user so that the script will run in that user's context. The script runs on the processor that SU is authenticated against.

Telnet is entirely different. With Telnet you are simply sending keystrokes to a remote processor. The script does not run on the switch, it runs on your computer. It is like the KiX SendKeys() function and just like SendKeys() is prone to timing issues.

The best way to get the information would be to use SNMP but that would involve a fair learning curve.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#72136 - 2002-12-11 12:04 AM Re: Can Kix do this? (Perl\Auto login)
Richard H. Administrator Offline
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
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1045 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.062 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org