473,322 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

perl expect in Network automation

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 15209
talexb
1
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
@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
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...
0
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...
0
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....
1
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...
21
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...
3
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...
10
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...
1
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...
8
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.