Aimless Posted May 29, 2010 Share Posted May 29, 2010 Can someone please tell me what this code: private function Run($sCommand) { require('auth.php'); require('GetServer.php'); $sCommand = 'cmd /C '.$sCommand; $oShell = new COM("WScript.Shell"); $oShell->Run($sCommand, 0, false); return true; } public function Start() { require('auth.php'); require('GetServer.php'); $this->Run('start /D "'.GAME_DIRECTORY.'" /B '.GAME_BIN_NAME); return true; } public function Stop() { require('auth.php'); require('GetServer.php'); $this->Run('taskkill /F /IM '.GAME_BIN_NAME.' /T'); return true; } would be for Linux, this is working fine to Start and Stop applications on Windows but of course not for Linux as I need to change some of the code, but I'm not sure what to change. All help very much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/ Share on other sites More sharing options...
Aimless Posted May 29, 2010 Author Share Posted May 29, 2010 First person to help will get a $1 as thanks Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1064974 Share on other sites More sharing options...
r.osmanov Posted May 29, 2010 Share Posted May 29, 2010 use http://www.php.net/manual/en/function.popen.php And also forget about WScripts in Linux There are great and much more powerful bash, tcsh, sh shells. I suggest to move to Linux(of practically any disro) since it is less restrictive, more reliable, much more powerful and more interesting as well Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1064982 Share on other sites More sharing options...
Aimless Posted May 29, 2010 Author Share Posted May 29, 2010 Hi, Thanks but no luck. public function Start() { require('auth.php'); require('GetServer.php'); //$this->Run('start /D "'.GAME_DIRECTORY.'" /B '.GAME_BIN_NAME); popen("/samp/samp", "r"); // return true; } popen("/samp/samp", "r"); It's not doing anything! Can someone tell me how to start an application in linux, my application is located at /samp/samp, an example on how to start it will do Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1064983 Share on other sites More sharing options...
r.osmanov Posted May 29, 2010 Share Posted May 29, 2010 popen("/samp/samp", "r"); // return true; Look at the example #2 at the page http://www.php.net/manual/en/function.popen.php You should not only open the process, but also read it's output Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1064984 Share on other sites More sharing options...
r.osmanov Posted May 29, 2010 Share Posted May 29, 2010 Are you sure it returns just TRUE? It should normally return file handle Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1064989 Share on other sites More sharing options...
Aimless Posted May 29, 2010 Author Share Posted May 29, 2010 Are you sure I have to read it, can someone provide me an example of this? Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1064990 Share on other sites More sharing options...
r.osmanov Posted May 29, 2010 Share Posted May 29, 2010 $command = './buttons'; $command = $commandJob.' > /dev/null 2>&1 & echo $!'; exec($command ,$op); $pid = (int)$op[0]; if($pid!="") { sleep(4); exec("kill -9 $pid", $output); } 'buttons' is an executable in my current folder. Replace it with your path Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1065005 Share on other sites More sharing options...
r.osmanov Posted May 29, 2010 Share Posted May 29, 2010 Are you sure I have to read it, can someone provide me an example of this? I'm sorry. This is a specific thing. Of course, you should not always read it. exec() with Linux shell command pipe tricks will do the job. I thought of another stuff when posted the reply. Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1065010 Share on other sites More sharing options...
Aimless Posted May 29, 2010 Author Share Posted May 29, 2010 This may not be appropriate but I haven't had any luck with what you guys have kindly suggested, so if anyone can make those three little segments of code in the original post I will PayPal them $3 as thanks, please PM or MSN me(trunetworkenquiries@gmail.com) if you can do it. Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1065017 Share on other sites More sharing options...
Aimless Posted May 29, 2010 Author Share Posted May 29, 2010 No worries, I worked out how to do it in a simple way, thanks for your help guys Quote Link to comment https://forums.phpfreaks.com/topic/203262-need-some-help-windows-to-linux/#findComment-1065046 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.