ViaThinkSoft CodeLib
Dieser Artikel befindet sich in der Kategorie:
CodeLib → Programmierhilfen → PHP
#!/usr/bin/php
<?php
error_reporting(E_ALL | E_NOTICE | E_STRICT | E_DEPRECATED );
function getArgWarningCritical() {
$shortopts = "";
$longopts = array();
$shortopts .= "w:"; // Requires value
$longopts[] = "warning:"; // Requires value
$shortopts .= "c:"; // Requires value
$longopts[] = "critical:"; // Requires value
$options = getopt($shortopts, $longopts);
$arg_warning = null;
if (isset($options['w'])) $arg_warning = $options['w'];
if (isset($options['warning'])) $arg_warning = $options['warning'];
if (is_null($arg_warning)) return false;
$arg_critical = null;
if (isset($options['c'])) $arg_critical = $options['c'];
if (isset($options['critical'])) $arg_critical = $options['critical'];
if (is_null($arg_critical)) return false;
return array($arg_warning, $arg_critical);
}
$ary = getArgWarningCritical();
if (!$ary) {
fwrite(STDERR, "Syntax: $argv[0] -w|--warning <warningLimit> -c|--critical <criticalLimit>\n");
exit(2);
}
$arg_warning = $ary[0];
$arg_critical = $ary[1];
echo "Got: $arg_warning : $arg_critical\n";
Daniel Marschall
ViaThinkSoft Mitbegründer
ViaThinkSoft Mitbegründer