capture in telnet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting capture in telnet
# 1  
Old 09-26-2006
capture in telnet

I'm trying to capture the files that this command types out, but i'm not able to do it. I'm pipeing everything to the telnet command because if i dont the connection closes. Any suggestions.


#!/bin/ksh

hostn='x.x.x.xx xxxx'
(echo "open $hostn\r"
sleep 3
echo " \r"
sleep 2
(echo "dir disk1:\r"; sleep 3 ; echo "\r") | tee > /usr/autoprog/prod/rob/dump2
echo "\r"
sleep 2
grep -i c12kprp-diag-mz.RELEASE66 < /usr/autoprog/prod/rob/dump2
rcode=$?
echo "$rcode"
sleep 2
echo "dir disk1:\r"
sleep 3
grep -i "size"
rcode=$?
echo "$rcode"
sleep 2
) | telnet &
exit

Results:

rommon 83 >
rommon 83 > <=== It's trying to save it to dump2 file here. Right?
rommon 84 >
rommon 84 > 1

monitor: command "1" not found
rommon 85 > dir disk1:
File size Perms File name
15803788 -rw- c12kprp-diag-mz.RELEASE66
25899492 -rw- c12kprp-p-mz.120-32.S.bin
3009536 -rw- c12k-fpd-pkg.120-32.S.pkg
0 drw- LOST.DIR
3009536 -rw- c12k-fpd-pkg.120-32.S1.pkg
3020288 -rw- c12k-fpd-pkg.120-32.S3.pkg
rommon 86 >
rommon 86 > 1

monitor: command "1" not found
rommon 87 > Connection closed by foreign host.

If i dump the results of file dump2. I get:
% more dump2
dir disk1:
<=== Where's the output????
Smilie
I've tried it without the "tee" and i still just get dir disk1:
Is there a better way of saving a couple of line after "dir disk1:" to maybe a variable to that i can compare it.
Thanks for any help
# 2  
Old 09-26-2006
[edit] Figured it out.

The echoes and the execution of them are completely seperate, you realize. Just because you echo something doesn't mean it's executed simultaneously -- they're just words flying over a pipe, not waiting for anything. Which means the "grep -i c12kprp-diag-mz.RELEASE66 < /usr/autoprog/prod/rob/dump2" might happen before you get any results.

How about moving the pipe, redirection etc. outside of the telnet block? It'll make it a lot easier to see what's doing what at least.

Last edited by Corona688; 09-26-2006 at 06:15 PM..
# 3  
Old 09-26-2006
Can you give me an example i'm still kinda new to this.
Thanks
# 4  
Old 09-26-2006
Instead of (echo something | tee | grep something ) | telnet, how abut (echo something) | telnet | grep something
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Capture PRSTAT

Is there any scripts to capture the process which use more than 5% CPU from prstat output? (9 Replies)
Discussion started by: tharmendran
9 Replies

2. Shell Programming and Scripting

Help using telnet to capture log file with autogenerate timestamp

Hello, I'm just joining, and looking for a solution to my problem. I have an app act as server which forward log data using telnet (server). And in my centos machine, act as a telnet client to capture the data, and an application called recorder which readd those log data and to process it then... (4 Replies)
Discussion started by: eddlinux
4 Replies

3. UNIX for Dummies Questions & Answers

Difference Between Krb5-telnet And Ekrb5-telnet

Hi, I want to know the difference between these two services. Both are under xinetd. Both are used for enabling and disabling Telnet service. So, can somebody please explain me the difference between the two ? Thanks in advance :) (0 Replies)
Discussion started by: kashifsd17
0 Replies

4. UNIX for Dummies Questions & Answers

Automatically login in the telnet from present telnet

Hi, I was writing one script which includes to switch to the another telnet automatically from the present telnet server. I was using rlogin but firstly it takes the same user name of the present telnet and secondly it is prompting for the password. But i want to switch to the another telnet... (2 Replies)
Discussion started by: Prateek
2 Replies

5. UNIX for Dummies Questions & Answers

Automatic logging (capture screen output) of telnet/ssh sessions on a Solaris node

Hi I am working in Solaris 10 and I want to monitor logs for every telnet/ssh session that tries to connect to the server. I need these logs to be generated in a file that I can fetch using ftp. I am a new user and a stepwise detail will be great BR saGGee (3 Replies)
Discussion started by: saggee
3 Replies

6. Programming

how to capture OS name using C/C++ code

Hi, I want to know the os name via c/c++ source code.so please help me to do the same. I will appreciate if anyone can provide me the source code. Thanks in advance.. (9 Replies)
Discussion started by: smartgupta
9 Replies

7. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

8. Shell Programming and Scripting

script to capture

Hi In my production server some user runnig some scripts to get some data. I need a script to capture this user script code. best rds ab (5 Replies)
Discussion started by: aboorkuma
5 Replies

9. UNIX for Advanced & Expert Users

Capture Value from file

I have a file in the following Format Fundid: 100-BankA AccountNumber Balance 1 200 2 300 3 400 FundId:123321-BankB AccountNumber Balance 1 200 3 100 ........... I can have N number of funds. (1 Reply)
Discussion started by: kris01752
1 Replies

10. UNIX for Dummies Questions & Answers

screen capture

I was wondering is there something out there for Solaris 7 for screen capture? Also it would really help if there was some software out there that can record whats happens on the screen for like 10 seconds or how ever long I need it to. I did a search but doesn't seem to be alot out there. (10 Replies)
Discussion started by: merlin
10 Replies
Login or Register to Ask a Question