Solved

how to send data on a port n return on # prompt

Posted on 2003-12-10
7
340 Views
Last Modified: 2010-04-21
Hi all,
 
I want to send some data or a packet to a tcp port on a socket.
I tried
# telnet <ipaddr> <port no> < test
where test is a file contains a packet.
 
It gives me acknowledgment, but it doesnt come out from the connection. And do not accept escape char eg. ^] or ^D.
I have to kill the process to terminate.
 
How to return on # prompt without killing the process?
Bcos i want to schedule the same process.
 
Please suggest.
 
Thanks,
rishi
0
Comment
Question by:rishi_dongre
  • 3
  • 3
7 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 50 total points
ID: 9911701
what about notup and running in background?
nohup telnet <ipaddr> <port no> < test &

0
 

Author Comment

by:rishi_dongre
ID: 9911917
hi liddler,
Your cmd gives me # promt but it dosent close the connection.
Means "telnet" session running continueously.
I want the telent connection also be closed.(The msg like "Connection closed by foreign host")
I m killing the session manually and it kills the connection established with socket.

regds,
0
 
LVL 11

Expert Comment

by:griessh
ID: 9911970
rishi

Could you let us know what's in your <test> file?

=====
Werner
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:liddler
ID: 9912005
you can kill the pid of the telnet session,
i.e.
ps -ef | grep telnet
to get the pid
then kill (or kill -9) the pid
IF it was the last command you ran from the command line
kill -9 %1
0
 

Author Comment

by:rishi_dongre
ID: 9912050
Griessh,
Its a data packet which i send to the server's port and the application read it and acknowledge accordingly.
eg. test file-- 123ADFD3ERE12123432FDSF3434
# telent 123.23.23.12 1234 < test
Connecting to ..
Escape char '^]'
345FKD9094 ( this is the acknowledgement)

And if i do following, i m succeeding.
# telnet 123.23.23.12 1234
Connecting to...
Esccape char...
123ADFD3ERE12123432FDSF3434 ( here i m pasting the string)
345FKD9094Connection close to foreign host
#
0
 

Author Comment

by:rishi_dongre
ID: 9912069
hi lidder,
I m doing the same already. But i m looking for the best way bcos i want to schedule it thru cron.
0
 
LVL 18

Expert Comment

by:liddler
ID: 9912219
#!/bin/ksh
telent 123.23.23.12 1234 < test &
sleep 5
kill $!

As the script that cron calls
i.e. do the telnet, sleep (maybe 5 seconds is too long, or you may not need any sleep), then kill the previous backgroud job (i.e. the telnet)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question