0

echo "show run"
the above commands gives input to terminal of router and then displays output on terminal. i want the output of this specific command to be redirected to the file. please help me

2
Contributors
5
Replies
7
Views
4 Years
Discussion Span
Last Post by Watael
0

echo "show run" > filename

Anything similar to this will redirect this text "show run" to the file and not the output of router.

0

???

show run > file

please be more precise about the context.

what's the router?
what OS?
what shell?
...

0

(
echo open x.x.x.x
sleep 2
echo "usrname"
sleep 1
echo "pass"
sleep 1
echo "sh run | s pim "
sleep 1
echo 'sh run | i hostname'
sleep 1
echo "sh ip int br | i Loopback"
sleep 1
echo "sh inv | i SN"
sleep 1
echo "logout"
sleep 1
) | telnet

Above is the simple telnet program.
I'll try to explain the problem.
Here the echo command is used to pass the commands to router console and not to print the text. So whenever i use redirection for particular line in this program, it redirects the command itself and not the output which router will give.

0

sorry, I don't have experience with telnet.

subshell can be avoided using a list :

{
command1
command2
} | command >file

are all those echo useful? you could use a here-doc

telnet <<EOF >file
open x.x.x.x
sleep 2
usrname
sleep 1
pass 
sleep 1
sh run | s pim 
sleep 1
sh run | i hostname
sleep 1
sh ip int br | i Loopback
sleep 1
sh inv | i SN
sleep 1
logout
sleep 
EOF
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.