LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2006, 04:39 AM   #1
kharerohit
LQ Newbie
 
Registered: Feb 2006
Posts: 3

Rep: Reputation: 0
Help in scripting related to router information gathering.


I have written script for gathering information from the router shown as below:

#!/bin/sh

USERID=
PWD=
PWD1=
dir=`pwd`
ip=
intface=
DATE=`date +'%m%d'`
Time=`date +'%H%M'`
(echo "$USERID";\
echo "$PWD";\
echo "en";\
echo "$PWD1";\
echo "sh ip cache flow";\
echo "q";\
sleep 30 )| telnet $ip > $dir/info$ip$DATE$Time.txt

But through this I can run only single command or set of commands in same file at one logging into router.

Can anyone help how to get the result from the router for different commands in different file without logging again and again into router?
 
Old 03-17-2006, 05:37 AM   #2
pcweirdo
Member
 
Registered: Oct 2004
Location: Melbourne-ish, Australia
Distribution: Gentoo, Windows XP Pro
Posts: 58

Rep: Reputation: 15
I'd use Perl for this, though there are other languages for the job.

eg.
Code:
#!/bin/sh

USERID=
PWD=
PWD1=
dir=`pwd`
ip=
intface=
DATE=`date +'%m%d'`
Time=`date +'%H%M'`
(echo "$USERID";\
echo "$PWD";\
echo "en";\
echo "$PWD1";\
echo "sh ip cache flow";\
echo "q";\
echo "sh ip pat does not understand this router";\
echo "q";\
sleep 30 )| telnet $ip > perl -e '<STDIN>;open FILEONE, > $dir/info$ip$DATE$Time.txt; print FILEONE, $_; <STDIN>;open FILEONE, > $dir/info$ip$DATE$Time.txt2; print FILEONE, $_; <STDIN>;open FILEONE, > $dir/info$ip$DATE$Time.txt3; print FILEONE, $_; '
The Perl bit is far too long and could probably be condensed into some kind of loop. I've printed a line to each file, those files having the same name but with a number appended. Watch the syntax errors!

-pcweirdo.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help in some scripting related to router information gathering. kharerohit Linux - Networking 1 03-17-2006 10:22 AM
Gathering post breach information on linux xxx_anuj_xxx Linux - Security 3 11-12-2005 10:08 AM
Gathering computer system (linux )information in C minil Programming 2 03-09-2005 05:47 AM
Information Gathering xathras Linux - Networking 4 06-28-2004 01:23 PM
Information related to RAW partition RajaRC Linux - General 1 09-26-2003 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration