vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Small Code Help - View Topic
Topic Rating: *****
Printable View
Broken
Senior Member
****

[Avatar]
Lost Resolve

Posts: 1,741
Status: Offline
Gender: Male
Age: 18
Joined:  
Reputation: 22%  


pmtwitterskypemsnyahooaim
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:
 
  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. ?>
 


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.

Image
Ross
Administrator
*****

[Avatar]

Posts: 3,429
Status: Offline
Age: 22
Joined:  

Additional Groups:
Support Team
***


Reputation: 67%  


pmwwwtwittermsngtalk 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]
Lost Resolve

Posts: 1,741
Status: Offline
Gender: Male
Age: 18
Joined:  
Reputation: 22%  


pmtwitterskypemsnyahooaim
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.

Image
 Printable View

All times are GMT+0 :: The current time is 5:48am
Page generated in 0.2469 seconds
with 28 Database Queries and 0 cache files
This Forum is Powered By vForums (v2.3)
Create a Forum for Free | Find Forums