Quote:
Originally Posted by vershooter
HI, Newbie here.
I just want to ask how to do bash script like to telnet IP PORT() then after connected I will type status. then I will see how many connection I created. I want to create a script that for example connections is above 5 then it will restart a service. Do you have insight for this one.
|
As others have pointed out, there are MANY easily found examples of telnet scripts on this site, and thousands more you can find with a brief Internet search.
To add to that, I would strongly suggest you rethink your approach. First, telnet isn't even installed on most distros of Linux these days because it is horribly insecure, so your first step in your 'script' would be to install and configure an insecure service on your server. Then open your firewall ports to accommodate that service...neither is good. Second, you can use SSH easily, and (after you do a keyswap) can have your command on the same line, such as:
Code:
ssh user@server.com '<your command goes here>'
...and have it be secure and easier to use.
Aside from those suggestions, bear in mind that you can also easily have a script ON the server itself to monitor that service, and act accordingly, without the need to run any commands over the network.