Visit Jeremy's Blog.
Go Back > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.


  Search this Thread
Old 02-28-2007, 07:00 PM   #1
Registered: Oct 2006
Distribution: usually use arch
Posts: 103

Rep: Reputation: 15
scripting telnet sessions, redirect issue


while read ciscorouter
echo cisco
echo sho ver
sleep 1 
echo exit
)|telnet $ciscorouter > /var/tmp/version.$$
ver=`grep IOS /var/tmp/version.$$ | cut -d, -f2`
echo $ciscorouter $ver >> reportname
done < routerlist
should be self explanatory, goes through a list of cisco routers ( we have a couple hundred here ). for each router it telnets to it and does a sho ver then cuts that to just the IOS version and dumps the router name and version as side by side columns to a file.

my problem is I don't want any output to the terminal while this script is run. but when it runs I get a "connection to $ciscorouter closed by foreign host" dumped to the terminal for ever router it logs into. please help get rid of this extra output for me. thanks in advance
Old 02-28-2007, 07:16 PM   #2
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
You could redirect standard error ?
I think this is how you would do it ...
telnet $ciscorouter > /var/tmp/version.$$ 2> /dev/null
Old 02-28-2007, 07:48 PM   #3
Registered: Oct 2006
Distribution: usually use arch
Posts: 103

Original Poster
Rep: Reputation: 15
GAH, now I feel stupid. the actual script has a nested loop that goes and creates a list of the routers. I tried that redirect before but I put it on the wrong loop like a idiot. it is in working order now, thanks you.
Old 03-03-2007, 12:08 AM   #4
Registered: Dec 2005
Location: Detroit, Michigan
Distribution: Ubuntu
Posts: 86

Rep: Reputation: 15
A second possible solution would be to use snmp. I've written little ksh wrappers to scan through a list of boxes and scan them (snmpwalk) for the information I needed.
Old 03-03-2007, 02:18 PM   #5
Registered: Oct 2006
Distribution: usually use arch
Posts: 103

Original Poster
Rep: Reputation: 15
I've had snmp recommended to me before but it doesn't seem to be on our solaris 9 boxes. if its not part of the default solaris 9 install its very unlikely that we have it and even more unlikely that I'll be able to convince my boss to install it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
shell scripting - redirect thoyyib Linux - Software 5 05-31-2006 09:00 AM
Multiple Telnet Sessions rjcrews General 4 07-24-2005 04:07 PM
No. of telnet sessions zatka Linux - Networking 2 01-16-2005 02:36 AM
Logging telnet sessions Cynric Linux - General 2 08-14-2004 01:39 AM
telnet sessions acid_kewpie Linux - Newbie 7 07-17-2001 02:35 PM > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 08:52 AM.

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