Hi,
I'm trying to automate the transfer and processing of files between two systems to help test and compare a new server installation. The workflow is a bit complex but I'm basically modifying a script on server 'A' to push a file to server 'B' as standard input to another script.
Now, I can do it manually by:
On server A:
Code:
cat ./test.txt | nc -q 1 192.168.1.235 1112
Server B is 192.168.1.235, running a netcat in listening mode:
Code:
nc -l 1112 | /usr/local/bin/insert.php
This works fine as a one off, but I want to set up B so that it's listening constantly. I can't use the '-k' option to keep the listening port alive as it needs to start a fresh instance of insert.php - but that's easy to resolve using a loop:
Code:
while true ; do nc -l 1112 | /usr/local/bin/insert.php ; done
However, the connection from A is actually being called via a router in exim - which is a multi-threading mail server. This means that the code on A is being run concurrently a number of times. This caused a connection refused error for those that attempt to connect while another is connected.
the simplest thing seemed to be to use xinetd (I'm running Ubuntu) to call nc on B - so that could hadle the concurrency etc. HOWEVER, I can 't get it to work and I'm looking for help in configuring this.
I've tried the following config script:
Code:
service mailsock
{
disable = no
id = exim01-mailsock
flags = REUSE
bind = 192.168.4.235
type = UNLISTED
socket_type = stream
protocol = tcp
port = 1112
wait = no
user = root
server = /bin/nc
server_args = -l 1112 | /usr/local/bin/insert.php
instances = 10
}
But no luck. I've tried it without the port in the server_args parameter, without the '-l' option; I've tried having the server parameter set to 'tcpd' and the call to '/bin/nc' in the server_args too. But no success. Can anyone point out what I'm doing wrong with the config?
PS. I've restarted xinetd and server B is listening on port 1112 and accepting connections - but nothing gets piped into the script on server B.
Thanks