- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- telnet localhost here document
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2009 02:49 PM
тАО05-06-2009 02:49 PM
I am trying to get a script working on Red Hat Linux kernel 2.6, this works on HP-UX just fine but not on RHL.
# echo "SHUTDOWN" | telnet localhost 51001
works fine on HP-UX, it shuts down the process that is running on port 51001 and closes the port, this is the vendor recommended way, they don't want us to kill the PID but just do it this way.
the same one-liner on RHL has problems, it doesn't shutdown, it works if I do this:
# telnet localhost 51001
SHUTDOWN
But if I try to put it in a here document it wouldn't do it:
# telnet localhost 51001 <
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2009 07:56 PM
тАО05-06-2009 07:56 PM
Re: telnet localhost here document
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2009 01:20 AM
тАО05-07-2009 01:20 AM
Re: telnet localhost here document
I have no experience with a application stop in this condition, I just suggest you to check the xinetd.conf to see if telnet is enable, perhaps it could be the issue, or check if you have firewall..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2009 06:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2009 09:09 AM
тАО05-07-2009 09:09 AM
Re: telnet localhost here document
telnet from the command line works so disabling telnet is not the problem, but Matti's solution worked and I am really surprised.
Matti,
Can you explain why a sleep command after the SHUTDOWN helped?
I really appreciate your assistance.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2009 06:13 AM
тАО05-08-2009 06:13 AM
Re: telnet localhost here document
RedHat's behaviour is actually a known (mis)feature of the BSD implementation of the telnet command, while the HP-UX telnet is probably a descendant of the System V implementation.
Google found for me a discussion about this exact problem on NetBSD network technology mailing list back in 1995:
http://www.google.com/search?q=site:mail-index.netbsd.org+batch+telnet+EOF&filter=0
When a BSD telnet command gets EOF from its input, it immediately aborts the entire connection instead of sending whatever it still has in its outgoing buffers, closing its socket and then waiting for the network side to send any final messages before exiting.
Apparently the BSD behaviour was not changed, as the change could have caused the telnet client to get stuck in an infinite loop at EOF.
When there is a sequence of commands inside parenthesis (a subshell) and the output of that sequence is piped somewhere, the pipe closes only after the last command in the sequence has completed. So adding short sleep after the echo command and enclosing the echo + sleep into a subshell sequence with parentheses will make the pipe to remain open for a while, and telnet has enough time to actually send the piped data.
Netcat ("nc") would probably be a better tool for tasks like this: telnet might in some situations pollute the outgoing data with telnet option negotiation codes, while nc is guaranteed to be clean. The netcat man page even mentions the telnet EOF problem.
echo "SHUTDOWN" | nc localhost 51001
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2009 10:26 AM
тАО05-08-2009 10:26 AM
Re: telnet localhost here document
Thanks Much!
Thanks,
Shabu