• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

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

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.
  • 3
  • 3
1 Solution
what about notup and running in background?
nohup telnet <ipaddr> <port no> < test &

rishi_dongreAuthor Commented:
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.


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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

you can kill the pid of the telnet session,
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
rishi_dongreAuthor Commented:
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 1234 < test
Connecting to ..
Escape char '^]'
345FKD9094 ( this is the acknowledgement)

And if i do following, i m succeeding.
# telnet 1234
Connecting to...
Esccape char...
123ADFD3ERE12123432FDSF3434 ( here i m pasting the string)
345FKD9094Connection close to foreign host
rishi_dongreAuthor Commented:
hi lidder,
I m doing the same already. But i m looking for the best way bcos i want to schedule it thru cron.
telent 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)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now