LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-29-2018, 02:24 AM   #1
Vijay12289
LQ Newbie
 
Registered: Aug 2018
Posts: 1

Rep: Reputation: Disabled
Bash script to close last open terminal


Hi All,

I m newbie here. My company having requirement that, I have one application running, all users accessing server through putty terminal. I want to write a shell script that, only 20 putty terminal should be open. If 21st terminal open then I want to close that terminal immediately. How can I achieve this

Please help me..
 
Old 08-29-2018, 02:37 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 12,879
Blog Entries: 9

Rep: Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514Reputation: 3514
not enough information.
please read this: https://www.linuxquestions.org/linux...Ask_a_Question

if i had to guess, i'd say you don't write a script, but the software providing the connections should be capable of limiting those.
 
Old 08-29-2018, 03:14 AM   #3
Michael Uplawski
Member
 
Registered: Dec 2015
Location: Normandy, France
Distribution: Debian “testing” with very little “unstable”
Posts: 804
Blog Entries: 25

Rep: Reputation: 507Reputation: 507Reputation: 507Reputation: 507Reputation: 507Reputation: 507
Quote:
Originally Posted by ondoho View Post
if i had to guess, i'd say you don't write a script, but the software providing the connections should be capable of limiting those.
I beckon this.

If, for some reason, the demon in question is unable to do it, replace the demon.

For home-use, someone (not me) could suggest keeping a list of the 20 allowed connections, to update it frequently, and kill any process which corresponds to the 21st connection, which can be identified by the order of process-ids. That is messy and you should not listen.
 
Old 08-29-2018, 03:41 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,270

Rep: Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203Reputation: 4203
just a comment:
it is really hard (if not impossible) to know if a connection was initiated from putty (or from any [other] app)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problem with running bash script on open terminal window! gnome1919 Linux - Software 2 07-15-2014 08:02 AM
[SOLVED] need bash script to close terminal when program closes rrrssssss Programming 5 09-25-2013 04:17 PM
Not able to open the gnome-terminal through bash script on hot plug event. rohaanembedded Programming 6 05-28-2013 01:14 AM
How to make script close terminal window when complete??? taylorkh Linux - Newbie 2 08-27-2008 11:43 AM
ssh - how to close connection from bash script babag Linux - Networking 7 05-30-2008 10:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:09 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration