cleaning the house
This commit is contained in:
@@ -8,6 +8,7 @@ use Net::Telnet;
|
||||
my $server_name = "";
|
||||
our $t; #telnet server object
|
||||
my $data_path = path('lib/Dojo/Model/Data')->make_path;
|
||||
|
||||
sub simple{
|
||||
my $c=shift;
|
||||
my $n=$c->param("dreq")//"";
|
||||
@@ -18,16 +19,6 @@ sub simple{
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
|
||||
sub admin{
|
||||
my $c=shift;
|
||||
my $n=$c->param("dreq")//"";
|
||||
my $json = {status => "304"};
|
||||
$json = ($c->dbv->rmsgid ($c->param('id')))[0] if ($n =~m/^mensajes$/);
|
||||
$json = ($c->dbv->ecourse($c->param('id')))[0] if ($n =~m/^ecourse$/);
|
||||
$json = ($c->dbv->qcourse($c->param('id')))[0] if ($n =~m/^qcourse$/);
|
||||
$json = ($c->dbv->qplace ($c->param('id')))[0] if ($n =~m/^qplace$/);
|
||||
$c->render(json=>$json);
|
||||
}
|
||||
#==== candy =====================================================
|
||||
sub candy{
|
||||
my $c=shift;
|
||||
@@ -43,32 +34,36 @@ sub candy{
|
||||
$c->render(json => {a=>$r});
|
||||
}
|
||||
|
||||
sub turnOff{
|
||||
grep(/Result: true/,join('',sendT('host:deactivate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==0);
|
||||
}
|
||||
sub turnOn{
|
||||
grep(/Result: true/,join('',sendT('host:activate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==1);
|
||||
sub turnOff{
|
||||
grep(/Result: true/,join('',sendT('host:deactivate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==0);
|
||||
}
|
||||
|
||||
sub turnOn{
|
||||
grep(/Result: true/,join('',sendT('host:activate("'.$server_name.'")')))?1:0
|
||||
unless (isOn()==1);
|
||||
}
|
||||
|
||||
sub isOn{return grep(/\s$server_name/,sendT("host:list()"))? 1:0; }
|
||||
sub isOn{return grep(/\s$server_name/,sendT("host:list()"))? 1:0; }
|
||||
|
||||
sub sendT{
|
||||
commandT(shift);
|
||||
my @r = $t->getlines(All=>0);
|
||||
return @r
|
||||
}
|
||||
|
||||
sub connectT{
|
||||
$t = new Net::Telnet ( Port=>5582, Timeout=>1, Errmode=>'return' );
|
||||
# $t = new Net::Telnet ( Port=>5582, Timeout=>1, Errmode=>'die' );
|
||||
return 1 if $t->open();
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub commandT{
|
||||
$t->getlines(All=>0);#empty buffer
|
||||
$t->print(shift); #run istruction
|
||||
}
|
||||
|
||||
sub disconnectT{ $t->close();}
|
||||
|
||||
#=========================================================
|
||||
|
||||
Reference in New Issue
Block a user