Thanks to all!
Scrip did work fine. Here is:
[EMAIL PROTECTED]:/home# cat gsserver.pl
#!/usr/bin/perl -w
use IO::Socket;
use DBI;
$dbname="xxx";
$user="xxx";
$pass="xxx";
$dbh =
DBI->connect("DBI:mysql:database=$dbname;host=localhost;user=$user;password=$pass",{'RaiseError'
=> 1});
my $PORT = 5001; # pick something not in use
my $server = IO::Socket::INET->new( Proto => 'tcp',
LocalPort => $PORT,
Listen => SOMAXCONN,
Reuse => 1);
die "can't setup server" unless $server;
local $/ = "!";
my $file="./1.txt";
open FILE, ">>$file" or die "unable to open $file $!";
print FILE "[Server $0 accepting clients]\n";
close (FILE);
while (my $client = $server->accept()) {
$client->autoflush(1);
while ( <$client>) {
my $answer = $_;
open FILE, ">>$file" or die "unable to open $file $!";
print FILE "$answer\n";
close (FILE);
$_ = "insert into tracker values (NOW(), '$answer');";
$sth = $dbh -> prepare($_);
$sth -> execute();
print $client "\$Ok!";
}
close $client;
}
I did write watchdog script to keep running gsserver.pl
#!/usr/bin/perl -w
my $str=`ps -ax|grep gsserver.pl|grep -v grep`;
if ($str gt '') {
print $str;
}
else{exec("/home/gsserver.pl&");}
and setup it in crontab. The gsserver.pl in RAM permanently. But it not work
, i did left system on several days, and script did not answer for requests.
But it`s running.
What may be wrong?
Respect, Max Rodkin
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/