August 15th, 2005 14:00

The CLI interface is basically an ascii interface over a telnet session.  There are many way to implement scripts to the CLI.  I have done so using Perl for example or even simple shell scripts.  To do more interactive parsing to process the CLI output you need to use something like Expect to process the output from the CLI to make decision.
 
However if all you want is to initiate the operation to download the file but don't worry too much about parsing resulting output and doing anything complex you could even use the scripting language on the Teraterm Pro application.  Anyway, the general answer is yes, you certainly can script the operation to download the configuration and save it.
 
BTW, if you use Dell OpenManage Network Manager application, it has the feature which allows you to schedule configuration backup of these configuration.  There are also many other capabilities available to you for managing your switches.  This application is also free for download from Dell.
 
 
 
Cuong.

2 Intern

 • 

128 Posts

August 15th, 2005 14:00

Cuong

Is there any way you could post a very generic script (perl/shell/or any other scripting language)?

August 15th, 2005 19:00

I use Perl scripts mostly for my work but I can't easily send it to you since it is pretty large - it handles alot of different cases generically so I can do testing on different CLI commands (its not written specifically for doing backup) and to use it you must install have Cygwin, Expect and Perl.  I tried to user perlcc to compile it so I can send it to you but it still requires link to cygwin DLLs.  Anyway instead of going down this path (which is more time then I have at the moment :-)), I decided to write up a very simple script you can use with "Teraterm Pro" (you can get it here: http://hp.vector.co.jp/authors/VA002416/teraterm.html) that you can use as an example.  You will need to expand on its capability (read the help for teraterm macro language) to include command line options and stuff like that so you can automate your script.  You can then easily add it to windows scheduler to schedule your download if you want.

You can do similar thing using Perl and Expect but its really beyond my scope to explain Expect here.  You may be able to do similar things in vbscript but I don't know vbscript so I can't help there.

Anyway here is the ttermpro script.  You can run this script using ttpmacro.exe (part of the teraterm package).  The ttpmacro has a command line interface that let you pass it a script (pass it the script I'm describing below) or you can double-click on ttpmacro.exe and it will prompt you for the script to run.  The scripting language in tterm is pretty simple but powerful enough to do what you need I'm sure.

Here is the script below (note lines begining with ; are comments):

; Script for backing up running config.

; The script assumes the following prompts are used by the switch.  You may need to adjust the prompt if you changed the

; name of the switch.  Also I'm assuming that the account you are using to login will immediately put you in global priviledge mode.

; This should be true if the account is level 15.  Global priviledge mode has a prompt of something like console# instead of console>.

; This means that I don't need to execute an enable first to get into the priviledge level to execute the copy command.  If this is not true

; then you may need to add an enable first.

CommandPrompt = "console#"

; The following is the prompt for user name during login.  Since some switch may prompt as "Username:" and some as "User Name:"

; it is safer to use "ame:" for the prompt.

UsernamePrompt = "ame:"

; This is the password prompt which maybe "Password:" or "password:"

PasswordPrompt = "assword:"

; You can make these parameters command line arguments quite easily.

; This script assumes that you have a TFTP server at 10.30.2.178.

TFTPServer = "10.30.2.178"

; It assumes that you are trying to connect to the switch at 10.30.2.177. 

SwitchIP = "10.30.2.177"

; It assumes that the login and password are as follows.  Note that tterm allow you to store the password encrypted in a file locally (see doc)

Username = "admin"

Password = "admin"

; Let's login to the switch

connect SwitchIP

wait UsernamePrompt

sendln Username

wait PasswordPrompt

sendln Password

; Once we login we can execute the copy command

; I'm assuming the name of the backup file is always backupfile but you can also take it from command line.

wait CommandPrompt

sendln "copy running-config tftp://"TftpServer"/backupfile"

wait CommandPrompt

sendln "exit"

2 Intern

 • 

128 Posts

August 15th, 2005 19:00

Thanks.

I'll download Teraterm but have been using Reflection. I'll give Teraterm a try. I know Reflection also has scripting capabilities so I'll give that a shot as well.

I'll have to learn Perl one of these days if I ever get a free moment.

2 Intern

 • 

128 Posts

September 21st, 2005 19:00

Okay...I'm not that good with Perl (it's new to me) but this is what I have to work with.


use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die');
$output = $telnet->open('xxx.xxx.xxx.xxx');

$telnet->waitfor('/User name: $/i');
$telnet->print('bilbo');
$telnet->waitfor('/Password: $/i');
$telnet->print('baggins');
$telnet->waitfor('/\$ $/i');
$telnet->print('sh bridge address-table');
$output = $telnet->waitfor('/\$ $/i');
print $output;


The error I'm getting is:

pattern match timed-out at C:\Perl\eg\telnet.pl line 5



Any suggestions?

2 Intern

 • 

128 Posts

December 13th, 2005 19:00

I've got this working via php instead of Perl.

1 Rookie

 • 

24 Posts

July 18th, 2008 15:00

I want to setup a script that I can kick off weekly to download the PC configs of all my switches. I'm not a programmer. What would the best tool be for me to accomplish this? I could use the format of the tera term sequence to copy the config to my ftp server. I was hoping I could setup an automated ftp from my ftp server to pull the configs out of each switch. Let me know what tool would be good to use for accomplishing this.

 

Thanks !

No Events found!

Top