Sponsored Content
Top Forums Shell Programming and Scripting Perl telnet to router run commands from file Post 302873705 by Chubler_XL on Tuesday 12th of November 2013 09:18:54 PM
Old 11-12-2013
Nice work, I've seen many posts here asking for something similar so I know others will find this useful.

The 600 sec timeout is a little long - do you encounter issues with some commands taking a long time to finish? I'd try reduce it to give feedback to users quicker, you can extend it again for the command processing part if needed.

Could be useful putting or die tests on all your waitfor() calls to assist debugging if router/prompts are wrong eg:

Code:
$t->waitfor('/Telnet password[: ]*/i') or die "No router pass prompt";

When doing these type of things I like to change the PS1 prompt to something more unique to ensure we are matching on the command prompt eg:

Code:
$t->print("PS1=READY#  \n");
$t->waitfor('/READY#$/') or die "No command prompt";

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl telnet to cisco router and compare the ping ms

All Please help, i will telnet to router to obain the ping status and compare, if higher than normal latency, i will have further action.. if i do the telent and in perl script then .... e.g the result i obtain from the router will be =' Success rate is 100 percent (5/5), round-trip... (4 Replies)
Discussion started by: optimus
4 Replies

2. Shell Programming and Scripting

Script to run on a router

I want to make a Perl script to telnet to a router and apply commands, and get the output of the commands in a file. Can any one help me in that? (2 Replies)
Discussion started by: moutaz1983
2 Replies

3. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

4. UNIX for Dummies Questions & Answers

Command to run multiple commands from a file.

I need a command, which could run mutliple commands from a file. Let's say, I have mv fileA1 fileB1 mv fileA2 fileB2 ..... mv fileA20 fileB20 I put these commands in a file, then I need a command to run the file as a whole so that I don't need to type 20 times... Anyone tell me how to... (8 Replies)
Discussion started by: kaixinsjtu
8 Replies

5. UNIX for Dummies Questions & Answers

check for a file and run some commands

Hi all, Can you guys please help me with this... I am on AIX and need to prepare a script which will 1. check for a file named do_backup in the current file system 2. If the file exists i need to run some commands and exit, if the file doesn't exist then sleep for 15 mins and try... (2 Replies)
Discussion started by: family_guy
2 Replies

6. Shell Programming and Scripting

Telnet to router and execute command

I am trying to write a shell script to execute some commands.. telnet <IP address of the router> wait 10 echo "username" echo "password" sh log exit but i am unable to execute it properly ..please help me .. thanks in advance Sri (1 Reply)
Discussion started by: srikanthus2002
1 Replies

7. Shell Programming and Scripting

Perl: connect to network devices, run set of commands

I am trying to write a script for my own use that will allow me to connect to network devices, then run a set of commands. I start with a list of ips in a text file. Each ip is on its own line. I start with a second file of commands. Each command on one line. for illustration .. the cmd.txt... (2 Replies)
Discussion started by: popeye
2 Replies

8. Linux

How to run commands with pipe from text file?

Hello, I have standard loop while read -r info; do command $info done < info in info text file I have multiple commands each on line that I want to execute. When I used them in console they worked, but not with this loop. This is one of the commands in info file: grep... (4 Replies)
Discussion started by: adamlevine
4 Replies

9. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

10. UNIX for Beginners Questions & Answers

Script require to do telnet & run few commands

I am new in scripting, I need script(BASH) which do telenet to one of the elements & run few commands , after running it successfully it will check status of files & exit. Help is greatly appreciated 🙏 (2 Replies)
Discussion started by: Vinesh_123
2 Replies
lg.conf(5)							File Formats Manual							lg.conf(5)

NAME
lg.conf - looking glass configuration file DESCRIPTION
lg.conf contains configuration for the looking glass scripts. The syntax is that of perl(1). It is used to set variables that affect run-time behavior and/or to locate resources. VARIABLES
The following variables are used (alphabetically): LG_AS_REG *** not implemented. LG_BGP_RT Allows show ip bgp neighbor commands that can produce heavy output, such as sh ip bgp neighbor <ip> advertised-routes for a transit customer when the neighbor address is followed by 'advertised-routes' for the sh ip bgp neighbor query. LG_CACHE_DIR Sets the location of the cache directory. The looking glass uses this to hold lock files, log files, and output from cached commands. Default: ./tmp Note that the default is relative to the directory where lg.cgi runs in the server's document root (e.g.: /usr/local/www/data/lg/tmp). LG_CACHE_TIME Sets the number of seconds that the looking glass should cache output from commands that tend to produce a lot of output, such as 'show ip bgp dampened-paths'. Default: 600 LG_CLOGINRC Defines the location of the cloginrc(5) that the looking glass should use. The path may be relative to the directory where the CGI scripts run in the server's document root. Default: $HOME/.cloginrc Note that the .cloginrc must be readable by the user or group that will be running the CGI and that clogin(1) will not allow a world readable .cloginrc. The user is normally that of the http server (httpd). LG_IMAGE Defines a html image tag (<img>) which, if defined, will be included at the top of the looking glass pages. It may contain any html as it is simply handed off to print(). Example: $LG_IMAGE="<img src=/icons/rancid.gif hspace=0> <font size=+2>FOO</font>"; LG_INFO Defines information in html format which, if defined, will be included at the bottom of the looking glass form page. It may contain any html as it is simply handed off to print(). Example: $LG_INFO="For Support contact <a href=mailto:webmaster@localhost>webmaster</a>"; LG_LOG Defines the fully qualified path name (i.e.: begins with '/') for the log file or the syslog(3) facility to use for logging. For syslog, the argument is the lowercase name of a syslog facility (see syslog.h) without the 'LOG_' prefix. Example: local0 Default: $LG_CACHE_DIR/lg.log LG_ROUTERDB Sets the location for the router.db file in rancid's router.db(5) format. It lists the devices that should be available to the looking glass users. Only those devices of supported types and with state 'up' are made available. If not defined and the default file does not exist, the looking glass will compile a list from the router.db files of all the groups present in rancid, that is, the list will be a concatenation of the available router.db(5) files. Note that if the concatenation method is used, it may be necessary to alter the mode of the router.db files in the rancid group directories, since rancid's default umask is 027 (see rancid.conf(5)). LG_STRIP Causes the LG to strip login information from the looking glass results. Since Expect often munges disabling echo when passwords are entered, this is a SECURITY CONCERN! However, this output can be very useful for debugging clogin problems. LG_STYLE Defines the URL of a style sheet to be used for HTML formatting. PATH Is a colon separated list of directory pathnames in the file system where rancid's login scripts, clogin(1) etc.) and programs needed within these, such as telnet(1), are located. Its value is set by configure. Should it be necessary to modify PATH, note that it must include $BASEDIR/bin (see above). Queries ................................... ENVIRONMENT
LG_CONF Location of lg.conf file. See the FILES section for more information. ERRORS
lg.conf is interpreted directly by perl(1), so its syntax follows that of perl. Syntax errors may produce quite unexpected results. FILES
/etc/rancid/lg.conf Configuration file described here. lg.conf is located by the value of the environment variable LG_CONF, in the CWD (current working directory), or the sysconfdir defined when rancid was installed, in that order. SEE ALSO
cloginrc(5), lg_intro(1), router.db(5) HISTORY
In RANCID releases prior to 2.3, lg.conf was located in the util/lg sub-directory of the install path. This was changed to be more consistent with common file location practices. 7 Jan 2004 lg.conf(5)
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy