Running Telnet in a script, want to save Telnet output, howtodothis???
Hello everybody.
I'm working in a company where we have lots of electronics we remotely control by telnet sessions.
I've made an shell script in Linux where I manage to run Telnet on a list of IP addresses, and thereby alter the configuration of the boxes. This is a very nice tool since I managed to do a complete reconfiguration of more than 700 boxes in one evening.
The problem is that I cannot grab the output from the telnet sessions and save to file. I need this feature to be able to query the result of the configuration.
If I do a redirection of the stdoutput to file by > or >> I only get the command saved.
This means that if I run the command "switch show port lan1" I get this:
Login: ---------
Password: *********
Login successful
--> switch show port lan1 (My command to query the status of port 1)
Switch Port information
--------------------------------------------------------------------------------
Port: lan1
Status Enabled
Link state Up
UpTime 018 days, 15:13:30
Port media type ISO8802-3 CSMACD
Configured speed/duplex Autonegotiate
Acceptable frame type packet sizes up to 1536 bytes (inclusive)
Broadcast limit Disabled
Multicast limit Disabled
Multicast/Broadcast rate lim -
Receive rate limit 6176 kbps
Transmit rate limit 6176 kbps
Current learned, lock state 0, not locked
Enabled flow control(s) Jamming
Pause
Send tagged pkts for VLAN(s) -
Port based VLAN vidar (1045)
Ingress filtering ON
802.1p Default Priority 0
802.1p Priority Disabled
--------------------------------------------------------------------------------
--> user logout
Logging out.
I get this on the screen, but I cannot save the output to file since I'm witin a Telnet session.
I managed to cature this screenshot by using PUTTY in Windows and logging it to file.
Is this possible in Linux within a script or is the another way to pick up the stdout stream.
I hope I managed to explain the challenge, and any reply will be highly appreciated.
Tnx in advance.
anil3
|