LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-30-2010, 03:07 AM   #1
g00se
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
Problems with netcat and xinetd


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
 
Old 10-30-2010, 08:44 AM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
if you are using xinetd you don't need to use nc on server B, just change the server = line to /usr/local/bin/insert.php and leave the server_args blank
 
Old 10-31-2010, 04:23 AM   #3
g00se
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks - that worked. I was over complicating matters .

Much appreciated.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/etc/xinetd.conf vs /etc/xinetd.d foampile Linux - Server 2 04-24-2009 05:33 PM
Problems wuth xinetd LinuxJnky421 SUSE / openSUSE 2 11-29-2005 03:15 AM
Xinetd dead --xinetd dead but pid file exists hillxy Linux - General 1 04-15-2004 02:10 PM
Problems starting Xinetd? christian-s Linux - Software 2 12-10-2003 06:40 PM
VSFTPD problems with xinetd paintcheck200 Linux - Networking 6 09-11-2003 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration