Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hi all, i'd like to use netcat in a script to send some text via sockets, but i don't know how to have it close the connection once it has finished sending all the text. usually when i use netcat i just hit ctrl-c, but i won't be there to do that while the script is running.
i was told about a -q option on some irc channels. i downloaded and installed @stake's nc 1.10 via yum (on a fedora box) but that didn't have -q. i then built gnu netcat 0.7.1 from their site and that didn't have -q either. however on my debian and gentoo boxes i have -q (got pkgs via apt and emerge, respectively)...but the system i need to run it on is the fedora box. (i also tried downloading & building the tbz from @stake's/securityfocus' site but that failed miserably.)
i've also looked into netpipes but that seems to be entirely different from what i want (the message sender is actually the server).
I don't understand the problem you are having. netcat will close the connection down automatically when it detects EOF on its stdin. So when there is nothing else to send, it shuts down automatically. When using this interactively, you can cause this by sending Ctrl-D.
neither GNU netcat nor @stake netcat closes the connection on eof on any box i've tried it on. and in all the time i've used netcat i've never ever seen that.
Quick howto on doing the same on non-debian box:
1. Surf into http://packages.debian.org/foo
2. Download the tar.gz and .diff.gz (maybe the dsc file too, for own reading).
3. Check the list of build-dependencies (none in this case).
4. Unpack and apply the debian patchset
Code:
tar xvfz foo_123.4.orig.tar.gz
zcat foo_123.4-5.diff.gz | patch -p0
5. If the package has patches split in parts (using dpatch), you have to apply them manually too.
Code:
cd foo_123.4.orig
chmod +x debian/patches/*
for i in `cat debian/patches/00list`; do debian/patches/$i.dpatch -patch ; done
touch patch-stamp
Netcat opens a TCP connection to port 23, sends "hello", sees the EOF on stdin and closes the connection and exits. Is this not what you are asking for?
cetialphav, you're wrong because the connection is closed *from the server side.* just because your netcat process ended doesn't mean that the client was the one who closed the connection. if you don't believe me just listen with netcat.
You mean listen with tcpdump (or ethereal). I did. It is not the server that closes the connection. The TCP connection is closed by the client (nc) and not the server. Are you using the -w option to netcat?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.