Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sed used with Telnet

Status
Not open for further replies.

astin

MIS
Jun 20, 2002
87
GB
hello
any help appreciated here -

i am fairly new to sed but am working through the examples
what id like to do is create a databased of ip addresses to names (like a hosts file) and have sed reference it when using telnet
for example - if i log into a router which has Ip address 10.20.30.40 and i do a 'show ip route' i would usually see
10.20.30.40 - connected - or similar
what i would like is to have it show
'my router - connected'
so far i have two issues - first - when i telnet x.x.x.x | sed 's/x.x.x.x/my router' i suddenly cannot see my cursor
and secondly - id like sed to reference a whole database of resolved ip addresses - but NOT use the /etc/hosts/ file - but one ive created
can someone help me out with this pls.

thanks
 
Are you trying to use "sed" with "telnet" interractively?
Are you actually trying to type stuff into that session?
Wow.
Not sure that's possible.


Trojan.
 
Trojan said:
I agree.
May I suggest you consider if you really need it?

And here is an idea regarding your 1st issue:
Your problems are caused by sed's output buffering: You don't see your cursor, and neither an echo of your typings. Only when you hit the enter key, you will see what you typed.
And I think you cannot reasonably switch buffering off, or you will prevent sed from doing what it should do, according to the manuals.

Just consider this scenario:
1) You type 'x.x.x.x', and you expect to see 'my router', don't you?
2) You type 'x.x.x.y', and you expect to see 'x.x.x.y', don't you?
3) You type 'x.x.x.', and what do you expect to see?
How could sed know whether you are going to continue with an 'x' or an 'y'?
Imho the only reasonable behaviour of sed here is to show nothing so far. And that's why I think you cannot reasonably overcome your 1st issue.

hope this helps
 
The scripting language Expect is the best tool for what you want. Pretty obvious as hoinz used the word expect in all 3 cases. Expect jumps back and forth between logic and interactivety.




Cheers,
ND [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top