Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # 1/27 update - quotes around command when calling script are no longer needed
- use Net::Telnet;
- # adjust these variables for your server
- my $host = "127.0.0.1";
- my $username = "user";
- my $password = "password";
- my $command = "";
- if ($#ARGV == -1) {
- print "worldserver command not provided\n";
- exit;
- }
- if ($#ARGV == 0) {
- $command = $ARGV[0];
- } else {
- for (my $l=0; $l <= $#ARGV; $l++) {
- $command .= $ARGV[$l];
- if ($l != $#ARGV) {
- $command .= " ";
- }
- }
- }
- $telnet = new Net::Telnet ( Port=>3443, Prompt=>'/TC\> $/' );
- $telnet->open($host);
- my $stat = $telnet->login($username, $password);
- if ($stat == 1) {
- my @results = $telnet->cmd($command);
- print @results if scalar(@results);
- } else {
- print "login error for user: $username\n";
- }
- $telnet->close;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement