how to Redirect the output of telnet command on a terminal to a file ?

(/home/user1)-> more script.sh

 
#!/bin/ksh
( echo open devicename
sleep 3;
echo user;
sleep 2;
echo password;
sleep 2;
echo "/info/dump";  --------->  This needs to redirect to a file .Can be number of  pages
 
sleep 2;
echo "exit" ) | telnet

You can use > or >> operator followed by file name

echo "/info/dump" >> abc.txt

Not sure if you can >|>> pipe within telnet, you probably just want to use the tee command.

Assuming your code works minus the logging...

#!/bin/ksh
( echo open devicename
sleep 3;
echo user;
sleep 2;
echo password;
sleep 2;
echo "/info/dump";  --------->  This needs to redirect to a file .Can be number of  pages
 
sleep 2;
echo "exit" ) | telnet | tee /tmp/out.file

I think should do you.