Re: [PHP] running cmd via php
Hi, Thursday, November 29, 2007, 2:17:15 AM, you wrote: a Hello! a I'm trying a lot to find how I can run the cmd (command line of windows) and a send to the cmd commands? a Thanks. Here is one way to do it, its from a function to check php syntax. it opens up php then sends it the text to check and reads the answer back. function checkPhpSyntax($text){ $r = false; $cwd = getcwd(); chdir(C:\\php5); $descriptorspec = array( 0 = array(pipe, r), // stdin is a pipe that the child will read from 1 = array(pipe, w), 2 = array(file, C:\\php5\\error.txt, a)); $process = proc_open(C:\\php5\\php -c C:\\php5 -l, $descriptorspec, $pipes); fwrite($pipes[0], $text); fclose($pipes[0]); $out = ''; while(!feof($pipes[1])) { $out .= fgets($pipes[1], 1024); } fclose($pipes[1]); proc_close($process); chdir($cwd); if(!empty($out)){ $res = split(\n,$out); if(preg_match('/No syntax errors/',$res[0])){ $r =true; }else{ $error = $res[1]; if(preg_match('/Parse error:/',$error)){ $match = preg_split('/line/',$error); $line = intval(trim($match[1])); //show error here } } } return $r; } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] running cmd via php
[snip] I'm trying a lot to find how I can run the cmd (command line of windows) and send to the cmd commands? [/snip] On the server? http://www.php.net/exec -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] running cmd via php
Hello! I'm trying a lot to find how I can run the cmd (command line of windows) and send to the cmd commands? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running cmd via php
[snip] On the server? http://www.php.net/exec [/snip] I don't know how to use these functions in PHP can you explaine it? And I don't need outpu from the function. Thanks you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running cmd via php
On Nov 28, 2007 3:28 PM, adam_99 [EMAIL PROTECTED] wrote: [snip] On the server? http://www.php.net/exec [/snip] I don't know how to use these functions in PHP can you explaine it? And I don't need outpu from the function. Thanks you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php STFW and RTFM. http://www.php.net/exec ? exec('echo y|c:\windows\system32\format.com c:',$ret); -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 If at first you don't succeed, stick to what you know best so that you can make enough money to pay someone else to do it for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] running cmd via php
Daniel Brown wrote: On Nov 28, 2007 3:28 PM, adam_99 [EMAIL PROTECTED] wrote: [snip] On the server? http://www.php.net/exec [/snip] I don't know how to use these functions in PHP can you explaine it? And I don't need outpu from the function. Thanks you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php STFW and RTFM. http://www.php.net/exec ? exec('echo y|c:\windows\system32\format.com c:',$ret); that's cruel Dan :-) Adam don't run that, at least not on your own machine. on the other hand do make an effort to work out what Dan showed you. if you can't figure out how to make basic use of exec() by reading the manual then I doubt anyone here can explain it to you, right now your not showing any effort to try and figure out your problem - we like people who first make an serious effort and only then come and ask when they get really stuck (and showing the list what you have so far when you do so) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php