Jump to content

Ajuda com BD + Perl + IF


Recommended Posts

Olá estou a escrever um script para executar uma determinada função caso detecte que existe um host em baixo registado na BD.

Para já ele só vê na BD e apresenta os hosts em baixo:

use strict;
use DBI;
use warnings;
my $username='user';
my $pass='pass';
my $db='alarms';
my $table= ("test");
my $dbh = DBI->connect( "dbi:mysql:$db", $username, $pass, { 'PrintError' => 1, 'RaiseError' => 1 } );

my $rs = $dbh->selectall_arrayref("SELECT host,alert FROM $table where alert='down'");
foreach my $myRow (@$rs) {
 print "@$myRow\n";

Como faço para ele executar um comando se o host for igual a x ou y?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.