On 6/21/07, Zoltán Németh <znemeth@xxxxxxxxxxxxxx> wrote:
2007. 06. 21, csütörtök keltezéssel 10.46-kor Richard Heyes ezt írta: > > hmm I thought the OP's question was about how can he get output/return > > value from the external program (the file name for example) - maybe it > > was my misunderstanding > > In which case I would still use shell_exec(): > > <?php > $output = shell_exec('ls -l'); > ?> > okay I admit my ignorance :) I didn't know about the return value of shell_exec, now I checked the manual and wow there it is... so both can be used to get output greets Zoltán Németh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
<? $filetoexecute = "somefile.sh"; $filetocreate = "newfile.txt"; $filetoappend = "existingfile.txt"; // To create a file, redirect the output with a single right carat: exec($filetoexecute.' > '.$filetocreate.' 2>&1',$ret); // To append to a file, redirect output with double right carats: // exec($filetoexecute.' >> '.$filetoappend.' 2>&1',$ret); file_exists($filetocreate) ? $file_written = True : $file_written = False; // Because we used 2>&1, errors are redirected to stdout // $ret contains the redirected error output from the command line ?> -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php