[Omaha.pm] Fwd: Perl / Expect / Minecraft
Jay Hannah
jay at jays.net
Sat Aug 25 18:02:13 PDT 2012
haha… Perl hack for Minecraft server management….
j
Begin forwarded message:
> From: "Robert L. Harris" <robert.l.harris at gmail.com>
> Subject: [Boulder.pm] Perl / Expect / Minecraft
> Date: August 18, 2012 1:32:46 PM CDT
> To: boulder-pm <boulder-pm at pm.org>
> Reply-To: boulder-pm at pm.org
>
>
> I'm looking to write a wrapper for my minecraft server. So far I have this:
>
>
> #!/usr/bin/perl
>
> use Expect;
> use strict;
>
> my $ServerStart=0;
>
> chdir('/usr/local/minecraft') or die "$!";
>
> sub worker {
> $ServerStart++;
> print "\n\n ** Server has been started $ServerStart times!!!\n\n";
> my $exp = Expect->spawn("java -Djava.awt.headless=true -Xincgc -Xms2048M -Xmx6144M -jar craftbukkit.jar");
> $exp->expect(undef, "java.io.IOException");
> print "\n\n\n **** Killing *****\n\n\n";
> my $pid = `pgrep -f 'java.*craftbukkit.jar'`;
> chomp $pid;
> kill 11, $pid;
> return;
> }
>
> while(1) {
> print "\n\n ** Cranking it up\n\n";
> worker();
> sleep 5;
> }
>
>
> I would like to add the following functionality but not sure how with Expect like this:
>
> 1) If I see certain phrases that go to stdout, kill the server, like the java.io.IOException or a couple other errors some modules throw.
> 2) At 2AM, send a command (list) and if I see "0/25" then kill -11 the server.
>
> Robert
>
>
>
>
> --
> :wq!
> ---------------------------------------------------------------------------
> Robert L. Harris
>
> DISCLAIMER:
> These are MY OPINIONS With Dreams To Be A King,
> ALONE. I speak for First One Should Be A Man
> no-one else. - Manowar
> _______________________________________________
> Boulder-pm mailing list
> Boulder-pm at pm.org
> http://mail.pm.org/mailman/listinfo/boulder-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20120825/49765d78/attachment.html>
More information about the Omaha-pm
mailing list