exec() and arrays...
Posted: Thu Oct 28, 2010 5:51 am
Hi all! I'm relatively new to PHP, so please forgive me if this is actually a stupid question!
background:
I am trying to make a webpage (which I will integrate into my company's nagios website) to restart selected services of windows servers.
I have found how to restart a specific service, and how to list the services using the exec function, but this is where my problem comes in...
I want to be able to input an IP address, and have it list the services on that IP, each one being a link to restart the service.
To be able to list the services of a server, I put it into an array and then have it print out all the contents...
problem:
when I list the services of a server, it lists them all on one line... how do I seperate each entry? and how would I go about adding tags around each line?
This is my code so far:
the PHP version is PHP Version 5.3.2-1ubuntu4.5 (if that makes any kind of difference)
Any help would be greatly appreciated
background:
I am trying to make a webpage (which I will integrate into my company's nagios website) to restart selected services of windows servers.
I have found how to restart a specific service, and how to list the services using the exec function, but this is where my problem comes in...
I want to be able to input an IP address, and have it list the services on that IP, each one being a link to restart the service.
To be able to list the services of a server, I put it into an array and then have it print out all the contents...
problem:
when I list the services of a server, it lists them all on one line... how do I seperate each entry? and how would I go about adding tags around each line?
This is my code so far:
Code: Select all
<?php
if($_POST['submit'] ) {
$ip = "$_POST[ip]";
$cmd = "net rpc service list -I " . $ip . " -U Administrator%Password";
exec($cmd, $output);
print_r($output);
} else {
echo "<form method='post' action=''>\n";
echo "<input type='text' name='ip' />\n";
echo "<input type='submit' name='submit' value='submit' />\n";
echo "</form>";
}
?>Any help would be greatly appreciated