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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to Redirect the output of telnet command on a terminal to a file ?
# 1  
Old 07-18-2012
how to Redirect the output of telnet command on a terminal to a file ?

Code:
(/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


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 07-18-2012 at 09:30 AM.. Reason: code tags
# 2  
Old 07-18-2012
You can use > or >> operator followed by file name
Code:
echo "/info/dump" >> abc.txt


Last edited by Scott; 07-18-2012 at 12:18 PM.. Reason: Code tags
# 3  
Old 07-18-2012
Not sure if you can >|>> pipe within telnet, you probably just want to use the tee command.

Assuming your code works minus the logging...
Code:
#!/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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirect output from terminal

i make a shell script. There has a line wget https://cisofy.com/files/lynis-2.1.0-88394c1affb9e23bd7390098947b3fd4b04e35e8.tar.gzWhen this line execute terminal show some text like this Resolving cisofy.com (cisofy.com)... 149.*.*.* Connecting to cisofy.com (cisofy.com)|149.*.*.*|:4444...... (4 Replies)
Discussion started by: Devils-ey3
4 Replies

2. Shell Programming and Scripting

Redirect the output of the telnet to a file

Hi, I am using cygwin. Below is my script that reads all ip ports for iplist.txt and telnets to it. ( file="iplist.txt" while read line do echo $line echo $(telnet $line) done <"$file" ) > output2.txt ~ while the output2.txt gets the first echo but does not show the second... (2 Replies)
Discussion started by: mohtashims
2 Replies

3. Shell Programming and Scripting

redirect time command output to file (cygwin bash)

I have set up a bash script to run a long list of things that I need to time. I would like to redirect the output of time to a file. I have set it up like, echo "Runtimes for servlet 4, 100K structures" > test_times.txt echo "" >> test_times.txt echo "runs where N=10" >> test_times.txt echo... (7 Replies)
Discussion started by: LMHmedchem
7 Replies

4. Shell Programming and Scripting

How to redirect the output of a cvs command to a file as well as the console.

Hi can anyone tell me how to redirect the ouput of a cvs command to a file as well as the console? i tried using cvs add <filename> | tee logFile cvs add <filename> 2>logFile 2>&1 All i could get is only on console or on file. Please help Thanks (2 Replies)
Discussion started by: ankitag2010
2 Replies

5. Shell Programming and Scripting

expect: redirect telnet to file

I've got some expect/tcl scripts. Now i want to add a function that allows to open a telnet connection and redirect the output to a logfile. On the shell/terminal i tried something like: 'telnet 192.168.123.123 12121 > /home/user/logging/log-telnet.log' and the telnet is redirected into the... (2 Replies)
Discussion started by: JaPatton
2 Replies

6. AIX

Unable to get the full content into a file when I redirect installp command output..

When i use the command to check the preview of the filesets to be installed using CLI # When using this commad 'm able to see all Preview view of the filesets to be installed installp -apgX -d "." all # When I redirected the same output to a file 'm able to see only half the details... (1 Reply)
Discussion started by: Sounddappan
1 Replies

7. UNIX and Linux Applications

How to redirect grep command output to same file

Hi Everyone, Can anyone please tell me, how can I redirect the grep command output to same file. I am trying with below command but my original file contains no data after executing the command. $grep pattern file1 > file1 Kind Regards, Eswar (5 Replies)
Discussion started by: picheswa
5 Replies

8. Shell Programming and Scripting

how to redirect the output of a grep command to a file inside a shell script

hi, i wat to get the output of a grep command in a file. but when i am trying out the same grep command in the unix prompt its working fine.. i am getting the output properly.. but when i am writing the same command inside my shell script , its just creating a new output file with no contents... (11 Replies)
Discussion started by: kripssmart
11 Replies

9. Solaris

how to redirect my output in a new terminal

Hi all, i type a command along with dtterm what i would like to have is that the output of the command to be shown in the new terminal . Any Idea on how to acheive this? (0 Replies)
Discussion started by: Sayantan
0 Replies

10. UNIX for Dummies Questions & Answers

Using telnet client from MacOSX's command line terminal

I'm completely new to Unix, but familiar with Mac OSX. I've just discovered the command line terminal feature of this new OS and I'm trying to learn how to telnet into my host's server to change permissions to allow executable cgi scripts for my website. Is there anyone who might be able to... (2 Replies)
Discussion started by: tylerl
2 Replies
Login or Register to Ask a Question