Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get ascii data and send it forward

Status
Not open for further replies.

Konri

Technical User
Jan 9, 2004
97
PL
Hi,
I want to receive Ascii data on port 9123 and send it forward to many other IP's on the same port or different ports. How can I do it.
I know that i can use "netcat" to catch network data

netcat -l -p 9123 >> net-data.txt &

I can look at the data using "tail"

tail -f net-data.txt

But how can I send this data forward to other ip addesses?
For example:
10.100.2.30 at port 9123
172.16.18.50 at port 32110
192.168.24.4 at port 5111

regards
K
 
Not sure if it works but you could try redirecting nc input on a port to output on a different port

something like

Code:
nc -l -p 9123 | nc -b -l -p 32110

QatQat


If I could have sex each time I reboot my server, I would definitely prefer Windoz over Linux!
 
correction,
from man pages it looks like you can't use -l with -p option.

so try something like

nc -l 9123 | nc 172.16.18.50 32110

QatQat



If I could have sex each time I reboot my server, I would definitely prefer Windoz over Linux!
 
It works only for one output. When I try to user more than one ip adresses, data is sent to the first one.
 
I've never used NetCat or "nc", so I'm just guessing, but maybe something along these lines...
Code:
rm nc_cache.dat && touch nc_cache.dat

tail -f nc_cache.dat | 10.100.2.30 9123    &
tail -f nc_cache.dat | 172.16.18.50 32110  &
tail -f nc_cache.dat | 192.168.24.4 5111   &

nc -l 9123 > nc_cache.dat
Just an untested guess.

 
Oops! Make that...
Code:
rm nc_cache.dat && touch nc_cache.dat

tail -f nc_cache.dat | nc 10.100.2.30 9123    &
tail -f nc_cache.dat | nc 172.16.18.50 32110  &
tail -f nc_cache.dat | nc 192.168.24.4 5111   &

nc -l 9123 > nc_cache.dat


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top