I gang

Perl telnet script

Hi,

I need a custom PERL script that opens a telnet connection to another application, executes a command and interpretes the result.

The first line in the script should be #!/path/to/perl -w followed by use strict;. Clean and good code is therefore required and warnings about uninitialized variables or else are not accepted.

The script has to run on CentOS 5.5 which comes with an older version of perl which is 5.8.8. Only the use of one addtional module is allowed which is Net::Telnet (Version 3.03-5) as available on CentOS 5.5.

The script shall take three command line parameters: ip, port and common_name

It establishes the connection to ip and port and sends the command "kill <common_name>". The resulting line gets interpreted. If the connection with the identifier <common_name> could be killed by the remote service you give back the exit code 0, if you couldn't connect via telnet the code 1, if the connection couldn't be killed 2, if the result of your command times out 3.

The remote application that is contacted via telnet is the openvpn management console.

Examples:

Common name found, connection killed (example with telnet client):

#####################################################################

[TEST]tunnel1 etc # telnet localhost 4242

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

INFO:OpenVPN Management Interface Version 1 -- type 'help' for more info

kill sgloeckner

SUCCESS: common name 'sgloeckner' found, 1 client(s) killed

quit

Connection closed by foreign host.

#####################################################################

Common name not found, connection not killed (example with telnet client):

#####################################################################

[TEST]tunnel1 etc # telnet localhost 4242

Trying 127.0.0.1...

Connected to localhost.

Escape character is '^]'.

INFO:OpenVPN Management Interface Version 1 -- type 'help' for more info

kill sgloeckner

ERROR: common name 'sgloeckner' not found

quit

Connection closed by foreign host.

#####################################################################

As in all our biddings - since we're an incorporated german company - the service provider has to be able to issue a valid invoice for his work - either with local tax payer id or vat code (if it's a company).

Best regards,

Sebastian

Færdigheder: Linux, Perl, Shell Script

Se mere: perl telnet script, perl telnet script example, perl telnet, perl telnet example, centos perl telnet example, perl telnet connection closed, telnet perl script code, perl telnet command script, telnet perl script, perl telnet openvpn, telnet perl example, centos telnet script, perl script telnet example, telnet perl script example, telnet perl, payer path, interpreted code, interpreted, best path, centos perl telnet script, centos perl script telnet, perl telnet client, script telnet, perl script telnet, openvpn telnet script

Om arbejdsgiveren:
( 53 bedømmelser ) Fentange, Germany

Projekt-ID: #986987