vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Small Code Help - View Topic
Topic Rating: *****
Printable View
dog199200
Guest
Small Code Help (30th Jan 10 at 6:06am UTC)
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:
 
  1. <?php
  2. $command = shell_exec('TASKLIST /FI "imagename eq Server.exe"');
  3.  
  4. if ($command) {
  5.  
  6. echo '<FONT COLOR=#00DD00><B>ONLINE</B></FONT>';
  7.  
  8. } else {
  9.  
  10. echo '<FONT COLOR=#DD0000><B>OFFLINE</B></FONT>';
  11.  
  12. }
  13. ?>
 

Ross
Administrator
*****

[Avatar]

Posts: 3,709
Status: Offline
Gender: Male
Age: 9 14
Joined:  

Additional Groups:
Support Team
***


Reputation: 45%  


pmwwwtwittergtalkvForum
Re: Small Code Help (30th Jan 10 at 11:01am UTC)
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.

Image
dog199200
Guest
Re: Small Code Help (30th Jan 10 at 11:26am UTC)
Edit: Nvm I found a work around using a batch File
 Printable View

All times are GMT+0 :: The current time is 3:22pm
Page generated in 0.1081 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums