The following process results in different behavior in Mac OS and Ubutu:

cat some_text_file | xargs a_shell_script.sh

a_shell_script.sh

#!/bin/bash
echo "$@" | telnet 127.0.0.1 123
exit 0

The TCP server listening on port 123 is scripted to process the contents of some_text_file. On my Ubuntu implementation of this process the length of input that the TCP server receives is the length of the some_text_file. On my OSX implementation however - it is a smaller fraction of the length ie. the input gets truncated somehow.

Note: This is not an xargs issue as far as I can tell. The number of args ($#) available to a_shell_script.sh is equal in both implementation.

Thank you!

link|improve this question
feedback

1 Answer

Without knowing enough about the implementation, I can only assume that your process on the listening end doesn't loop to recv(2) from the socket, but only reads once. The fact that you get everything at once on Ubuntu and you don't on OS X probably has to do with the TCP stack implementation on the two systems, but it's not something that should matter; instead, the code on the receiving end should poll the socket and read data as available.

Check out the socket(2) and recv(2) calls, and maybe post some code if you think it would help.

link|improve this answer
Thanks Alexandru : ) – user51327 Oct 5 '10 at 4:22
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.