LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   get output from telnet session? (https://www.linuxquestions.org/questions/linux-networking-3/get-output-from-telnet-session-521987/)

Manana 01-23-2007 06:01 AM

get output from telnet session?
 
Ok this is my problem: I have a script that uses expect, it logs(telnet) onto a ciscorouter and can excecute commands there.
I need to excecute a command on the ciscorouter and then send the output to my PC(where im running the script).

Something like this

send "show running-config" > /example/config

thats how i would like to do it but thats not working, how can i do this ?

Help much appreciated! Thanks!

acid_kewpie 01-23-2007 06:53 AM

the example i already gave you does this, does it not??

Manana 01-23-2007 07:06 AM

Thanks for the previous help, however the problem with your way of doing it is that i seem to be getting alot of other text in the logfile other then the output from the command wich is a big problem if i want to restore config from that file aswell.

With other text i mean the actual commands and stuff like that, maybe im doing it wrong. Any ideas? isnt it just possible to pipe the output to a local file?

acid_kewpie 01-23-2007 01:24 PM

it's just a case of turning logging on and off at the right time. you can see in my example i chop and change between log files to only caputer the relevant pasrts. i even type in "show run", change the log file and *then* press enter, so none of my input is listed.

Manana 01-24-2007 02:20 AM

Aha ok i see, cant really get it working here.
Im using a telnet session instead of ssh, so its a bit different.
Maybe i could just pipe all the output from the telnet session to file and then grep the parts i want.

I know i can grep a number of lines after a value but can i grep everything between two values ? like this:

1
2
want to grep
this text.
3
4

Can i grep everything starting from 2 ending at 4 ?

Thanks for all your help btw acid_kewpie! really need it :)


All times are GMT -5. The time now is 02:57 AM.