[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • 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.
 
Thanks,
rishi
0
rishi_dongre
Asked:
rishi_dongre
  • 3
  • 3
1 Solution
 
liddlerCommented:
what about notup and running in background?
nohup telnet <ipaddr> <port no> < test &

0
 
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.

regds,
0
 
griesshCommented:
rishi

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

=====
Werner
0
Independent Software Vendors: 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!

 
liddlerCommented:
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
 
rishi_dongreAuthor Commented:
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
 
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.
0
 
liddlerCommented:
#!/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

Independent Software Vendors: 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!

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