LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 05-02-2012, 09:18 AM   #1
omcdr
LQ Newbie
 
Registered: May 2012
Distribution: CentOS
Posts: 2

Rep: Reputation: Disabled
Xinetd, bash script and reset connection


I have simple bash script:

Code:
#!/bin/bash

if nc -w 3 -z 192.168.15.10 5532 <<< . &> /dev/null
 then
  echo 'Port is open'
  ssh -L 1523:127.0.0.1:1523 -gNnT -p 5532 192.168.15.10 &
fi
exit 0
Script is working, but with xinetd serwice:

Code:
service script
{
        disable         = no
        socket_type     = stream
        protocol        = tcp
        wait            = no
        user            = root
        server          = /root/script.sh
        log_on_success -= HOST
        log_on_failure += HOST
        instances = 1
}
script after telnet connection is hang up, I see echo characters in telnet console.

How to reset connection in xinetd service after script execution ? exit 0 not working.
 
Old 05-02-2012, 09:54 AM   #2
em31amit
Member
 
Registered: Apr 2012
Location: /root
Distribution: Ubuntu, Redhat, Fedora, CentOS
Posts: 190

Rep: Reputation: 55
telnet to what ? you are using SSH session in script not telnet. information is not clear here!!!!
 
Old 05-02-2012, 03:21 PM   #3
omcdr
LQ Newbie
 
Registered: May 2012
Distribution: CentOS
Posts: 2

Original Poster
Rep: Reputation: Disabled
Telnet to my xinetd service with bash script:


Code:
# netstat -ltnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 192.168.2.20:2001            0.0.0.0:*                   LISTEN      13756/xinetd
...


# telnet 192.168.2.20 2001
Trying 192.168.2.20...
Connected to 192.168.2.20 (192.168.2.20).
Escape character is '^]'.
Port is open
and telnet connection is still active.
How to break connection after script execution ?


In console mode script works 0.1 s

Code:
# time /root/script.sh
Port is open

real    0m0.129s
user    0m0.004s
sys     0m0.045s
 
  


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
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
Install ruby gems - connection reset, connection reset..... deco81 Linux - Software 1 06-16-2010 04:47 PM
Bash Script to log off of ssh connection Betzie Programming 4 07-07-2009 04:29 PM
Bash script to reset admin password with chntpw hal8000b Programming 2 12-15-2008 02:47 AM
ssh - how to close connection from bash script babag Linux - Networking 7 05-30-2008 09:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:19 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