[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] 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
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 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 > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
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