
| Current Path : /var/www/web-klick.de/dsh/90_akt/PPLTest.old/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/90_akt/PPLTest.old/prg.pl |
use DivBasicF::FileComSimple;
use Data::Dumper;
my $prg = shift;
my $par;
if ($ARGV[0] =~ /___no_edit___/) {
$par = shift(@ARGV);
}
#my $database = "localhost:xtest:xtest:test";
my $database = "xtest.db";
if ($ENV{'PPLDB'}) { $database = $ENV{'PPLDB'}; }
my $com = DivBasicF::FileComSimple->new(["$database,cxtest",67002000,100,2]);
my $erg; my $zaehler; my $o; my $o1; my $prg1;
open(FFILE,"<".$prg);
my $text = join("",<FFILE>);
close(FFILE);
if ($prg eq "new.ppl") {
$text = <<'TEXT_ENDE';
sub test_item {
$v->{'name'} = "new";
$v->{'generator'} = "newtest";
$v->{'next'} = $v->{'generator'};
$v->{'dbfunc'} = ["status",1];
}
sub condition { 1; }
TEXT_ENDE
}
if ($text =~ s/^CONTINUED... +(.*?) *\n//s) {
$com->connection($1);
while ($text =~ s/---xxx---([\n ]*)(.*?)([\n ]*)---xxx---/---xxx---/s) {
push(@$erg,$2);
}
$com->msg(["step",@$erg]);
$text = "WAITING... " . $com->get_connection() . "\n";
open(FFILE,">".$prg);
print FFILE $text;
close(FFILE);
print $text;
}
if ($text =~ /^WAITING... +(.*?) *\n/s) {
$com->connection($1);
my $erg = $com->get(2,7);
if (ref($erg)) {
unlink($prg);
$prg = shift(@$erg);
$prg =~ s/^([a-z0-9]+)\_(.*)$/$2.ppl/;
$erg = "CONTINUED... " . $com->get_connection() . "\n" .
join("\n\n---xxx---\n\n"," ",@$erg," ");
open(FFILE,">".$prg);
print FFILE $erg;
close(FFILE);
if (!$par) {
if (-f "/etc/hosts") {
system("joe $prg");
} else {
system("notepad $prg");
}
}
print "Output to $prg ...\n";
} else {
print $text;
}
}
elsif (!$text and $prg =~ s/\.ppl$//) {
$com->msg(["step","find",$prg]);
my $erg = $com->get(1000,7);
if (@$erg and $erg->[2]) {
open(FFILE,">".$prg.".ppl");
if ($erg->[4]) {
print FFILE "WAITING... " . $erg->[2] . "\n"
} else {
print FFILE "CONTINUED... " . $erg->[2] .
"\n\n---xxx---\n\nformular\n\n---xxx---\n";
}
close(FFILE);
}
$com->msg(["step","kill"]);
print "$prg killed\n";
}
elsif ($text and $prg =~ /^(.*)\.(.*)$/) {
$o = $1;
$o1 = $2;
$zaehler = 0;
opendir(DDIR,".");
while (0 == 0) {
$prg1 = readdir(DDIR);
last if (!$prg1);
if ($prg1 =~ /^$o\_\_(\d+)\.$o1/) {
$erg = $1;
if ($erg > $zaehler) {
$zaehler = $erg;
}
}
}
closedir(DDIR);
$prg1 = $o . "__" . sprintf("%03u",$zaehler+1) . "." . $o1;
$com->msg(["step",$text,@ARGV]);
$erg = "WAITING... " . $com->get_connection() . "\n";
open(FFILE,">".$prg1);
print FFILE $erg;
close(FFILE);
open(FFILE,">next.pl");
print FFILE "system(\"perl $0 $prg1 ___no_edit___\");\n";
close(FFILE);
print $erg . "Generated File: $prg1\n";
}
elsif ($prg !~ /\./) {
$com->msg(["step","list",$prg]);
my $erg = $com->get(1000,7);
shift(@$erg);
shift(@$erg);
foreach $o (@$erg) { # [gesresult,conn,objlock,sleep,name,result,
# remark,user,info,dyndata,status]
if ($o->[10] == 1) { # Abfrage Status
print sprintf("%4u",$o->[0]) . " " . sprintf("%4u",$o->[5]) . " ";
}
elsif ($o->[10] == 2) {
print substr(" (" . sprintf("%1u",$o->[3] - time()) .
") ",0,10);
}
else {
print " ";
}
print $o->[4] . "\n";
}
$com->msg(["step","kill"]);
}
else {
print "File not found...\n";
}
1;