Don't like ads? PRO users don't see any ads ;-)
Guest

OMnibus

By: a guest on Apr 27th, 2012  |  syntax: Perl  |  size: 1.11 KB  |  hits: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2. use DBI;
  3. use CGI;
  4. $co = new CGI;
  5.  
  6. if (@ARGV) {
  7. $Node = $ARGV[0];
  8. $Summary = $ARGV[1];
  9. $Identifier = $ARGV[2];
  10. }
  11.  
  12. print $co->header;
  13.  
  14. $database="glpi";
  15. $hostname="192.168.1.209";
  16. $login = "root";
  17. $mdp = "somone";
  18. $test = "netcool";
  19. $dsn = "DBI:mysql:database=$database;host=$hostname";
  20. $dbh = DBI->connect($dsn, $login, $mdp) or die "Echec connexion";
  21.  
  22.  
  23. $requete = "INSERT INTO `glpi_tickets` VALUES ('', '7', \"$Node\", NOW(), '', '', '', '', 'new', '', '', '', '', '', \"$Summary\", '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', \"$Identifier\" )";
  24. $sth = $dbh->prepare($requete);
  25.  
  26. $requete2 = "select ID from glpi_tickets where Identifier = \"$Identifier\"";
  27. $sth2 = $dbh->prepare($requete2);
  28.  
  29. $sth->execute();
  30. $sth2->execute();
  31.  
  32. while(my @row = $sth2->fetchrow_array){
  33. $id=$row['0'];
  34. }
  35.  
  36. my $commandes = "./nco_sql -server PRIMARY -user root -password azerty <<EOF
  37. update alerts.status
  38. set TicketNumber = $id
  39. where Identifier = '$Identifier' ;
  40. go
  41. exit
  42. EOF ;";
  43.  
  44. exec $commandes;
  45.  
  46.  
  47. $sth -> finish;
  48. $sth2 -> finish;
  49. $dbh -> disconnect;