Mam problem z skryptem restartującym serwer po crashu, po odpaleniu skryptu wywala mi:
./autores.pl: line 2: use: command not found ./autores.pl: line 8: my: command not found ./autores.pl: line 9: my: command not found ./autores.pl: line 10: use: command not found ./autores.pl: line 11: use: command not found ./autores.pl: line 16: my: command not found ./autores.pl: line 22: my: command not found ./autores.pl: line 23: my: command not found ./autores.pl: line 24: my: command not found ./autores.pl: line 25: {ALRM}: command not found ./autores.pl: line 25: TimeOut: command not found ./autores.pl: line 26: syntax error near unexpected token `&' ./autores.pl: line 26: ` &Start;'
Oto skrypt:
#!/usr/bin/perl -X use Socket; #----------------------------------------------------------- # Konfiguracja (Do ustawienia według opisu) #----------------------------------------------------------- my $host = "91.228.197.151"; # Adres IP serwera do sprawdzania (To jest ten zbindowany). my $port = "27018"; # Port serwera, na którym chodzi. use constant CHECKEVERY => 90; # Jak często sprawdzać serwer ? (Tutaj ustawiono co 90 sekund). use constant TIMEOUT => 20; # Jak długo czekać na jego odpowiedź zanim go zrestartujemy. # Poniżej podaj ścieżkę do skryptu uruchamiającego/restartującego serwer. # Oczywiście może to być także zwykła komenda zawierające odpowiednie opcje. my $cmd = "/root/zombie/restart.sh"; #----------------------------------------------------------- # Nie edytuj tego poniżej, chyba, że wiesz co robisz <img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/smile.png' class='bbc_emoticon' alt=':)' /> #----------------------------------------------------------- my $MAXLEN = 128; my $msg="\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00"; my $RET = "NONE!"; $SIG{ALRM} = sub { &TimeOut }; &Start; sub CheckServer { my $ipaddr = inet_aton($host); my $portaddr = sockaddr_in($port, $ipaddr); $RET = "NONE!"; socket(SOCKET, PF_INET, SOCK_DGRAM, getprotobyname("udp")) or die "socket: $!"; send(SOCKET, $msg, 0, $portaddr) == length($msg) or die "Blad wysylania zapytania.\n"; alarm(TIMEOUT); recv(SOCKET, $RET, $MAXLEN, 0); close SOCKET; sleep(CHECKEVERY); } sub Start { while (1) { &CheckServer; } } sub TimeOut { if ($RET eq "NONE!") { print "SERWER PADL, RESTART!\n"; $STARTSERV = `/usr/bin/perl -w $cmd`; print $STARTSERV . "\n"; } sleep(CHECKEVERY); close SOCKET; }
Perl zainstalowany, tak samo Socket (tego ja nie instalowałem wiec nie mam 100% pewności)
Za pomoc z góry dziękuje.