vForums Support :: Programming & Coding :: Programming Discussion :: Small Code Help - View Topic
 |  |
| Broken Senior Member
   
![[Avatar]](http://i25.photobucket.com/albums/c51/dog199200/Dont%20removm/brokenavi.png) Lost Resolve Posts: 1,741 Status: Offline Gender: Male Age: 18 Joined:
pmskypemsnyahooaim | | Small Code Help (30th Jan 10 at 1:06am EST) | | Hello,
I have a small script that I need a bit of help with. What it is suppose to do it check to see if a program is running and if the program is running it echo's back Online, but if the program is not running it echo's back Offline, but the problem is that it always and I mean always echo's back thats its online, even when the program isn't running, so can someone please fix this code for me? I would say it can be done in batch if needed but the problem is that I have to use almost the same exact thing in another file that requires it to be in php.
 Code: - <?php
- $command = shell_exec('TASKLIST /FI "imagename eq Server.exe"');
-
- if ($command) {
-
- echo '<FONT COLOR=#00DD00><B>ONLINE</B></FONT>';
-
- } else {
-
- echo '<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>';
-
- }
- ?>
| |
If you fall I’ll catch, if you love I’ll love, And so it goes, my dear, don’t be scared, you’ll be safe, This I swear. If you only love me back.
 |
| Ross Administrator
    
![[Avatar]](http://uploads.virtualforums.co.uk/forums/pokemon/vforums-qr1.png) Posts: 3,429 Status: Offline Age: 22 Joined:
Additional Groups: Support Team
  
pmwwwmsngtalk vForum | | Re: Small Code Help (30th Jan 10 at 6:01am EST) | | Write out what the value of "$command" is to find out what it says if the program is not running.
if($command) doesn't check what the value of $command is, it just checks that it has a value. | |
|
| Broken Senior Member
   
![[Avatar]](http://i25.photobucket.com/albums/c51/dog199200/Dont%20removm/brokenavi.png) Lost Resolve Posts: 1,741 Status: Offline Gender: Male Age: 18 Joined:
pmskypemsnyahooaim | | Re: Small Code Help (30th Jan 10 at 6:26am EST) | | | Edit: Nvm I found a work around using a batch File | |
If you fall I’ll catch, if you love I’ll love, And so it goes, my dear, don’t be scared, you’ll be safe, This I swear. If you only love me back.
 |
| |
 |  |
|