473,763 Members | 6,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

perl expect in Network automation

1 New Member
Can any one suggest any link for perl expect....
and few examples for automation of router and switch configurations .. apart from the tcl feature available in CISCO IOS
Dec 9 '06 #1
2 15240
talexb
1 New Member
Can any one suggest any link for perl expect....
and few examples for automation of router and switch configurations .. apart from the tcl feature available in CISCO IOS
You've looked at IPC::Run on CPAN already?
Dec 11 '06 #2
docsnyder
88 New Member
@perlandtcl

Here is a simple script to create a ssh session to a remote host:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/perl
  2.  
  3. use Expect;
  4.  
  5. #--- ENSURE TO HAVE SUFFICIENT COMMAND LINE ARGUMENTS ! ----------------------#
  6. if ( $#ARGV != 2 ) {
  7.   printf("USAGE: $0 <host> <user> <pw>\n");
  8.   exit(-1);
  9. }
  10.  
  11. $host = shift;
  12. $user = shift;
  13. $pw   = shift;
  14.  
  15. #--- CONFIGURATION -----------------------------------------------------------#
  16. $cmd    = "ssh -l $user $host";
  17. $prompt = "[Pp]assword";
  18.  
  19. #--- START SSH LOGIN SEQUENCE ! ----------------------------------------------#
  20. $exp = new Expect();
  21. $exp->raw_pty(1);  
  22. $exp->spawn($cmd);
  23.  
  24. #--- LOGIN AND INTERACT ! ----------------------------------------------------#
  25. $exp->expect(10000, [ $prompt => sub { $_[0]->send("$pw\n"); } ]);
  26. $exp->interact();
  27.  
  28. __EOF__
Feel free to substitute ssh by whatever (e.g. telnet, etc.).

Greetz, Doc
Dec 12 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

31
4802
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is great for pattern matching, text processing, and automated testing. Our company is really fixated on risk managnemt and the only way I can do enough testing without working overtime (which some people have ended up doing) is by automating my...
0
6447
by: Danny Jensen | last post by:
I need to test if certain processes on a unix box were running. I wanted to use whatsup gold to do the testing. First I needed to go to the whatsup configure>monitors & services menu to add this tcp/ip port 1555 service with the folowing lines: Send=psef /dj/myco/rf.monitor\r\n Expect=~1 the psef above is a command that the unix server executes. The unix box communicates back a 1 if the test is successful and a 0 if it is
0
9745
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
1
2749
by: graphman | last post by:
I have a perl script that I'm calling using php's shell_exec that uses an expect module to go to another system to pull tiff files. The php perl combination works great when I launch from the commandline: $php docpull.php I get the files I want. Everything is perfect. When I run docpull.php through the web server I get to the expect call in the perl script where the password is passed and the script fails.
21
34436
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
3
1265
by: SecureTalk | last post by:
I am interested in porting Perl programs I wrote years ago from Solaris based servers to run on a Apple Mac platform (latest OS). I have yet to purchase a the needed Mac hardware. I wanted to first get feed back on how easy it is to port the Perl code between these platforms. I have been out of the programming business for many years, so I do not want to have to do major rewrites. If it is basically making hardware specific changes I will go...
10
5167
by: kraj123 | last post by:
Hi Friends, I would apprciate, if anyone could help me out regarding coding tips for writing a perl script for automating a snapshot process. Snapshot is nothing but capturingn forms from different language database local servers like russia,japan..which are in csv file taken as input and comparing with present english database forms in our system and output it as definition file. this out put should be checkin to repository....this should...
1
1733
by: Perl Beginner | last post by:
Hi All, I have a very extensive Perl script using Win32. This is an automation script which manipulates various windows using the mouse and keyboard (using Win32::GuiTest). The various windows that I am manipulating are part of a software program that was written in Java. However, my Perl script is layered on top of this program, so it does not affect the Java code (I hope that makes sense). In other words, my Perl automation is just...
8
4225
by: gajendra98 | last post by:
Hi All I Have installed Active perl in my system and I am new to perl and automation...Could some one tell me how to install the perl modules and how to use those modules with the perl for autmating the website ... it will be very helpful for me to start automation...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.