Re: Simple Question: Reading exec(locate) results into an array
| From: | John Nichel | Date: | Wed, 27 Apr 2005 20:46:02 +0000 |
| Subject: | Re: Simple Question: Reading exec(locate) results into an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214043@lists.php.net to get a copy of this message | ||
Karl Fry wrote:
Hello all, I'm sure this is very rudimentary, sorry if this sounds ignorant. I've only dabbled a bit in other languages and I'm working with a small knowledge of php since I only use it on-and-off at my job. I scribbled up this script today at work off the top of my head for a customer who was looking for a printout of my company's PEAR location. I wanted something quick and easy that would be adaptable to find other items. I was surprised it even worked since I haven't really had a chance to dig into PHP yet: <?php $temp = exec("which pear"); $temp2 = exec("locate pear"); echo "which = $temp <BR><BR> locate = $temp2"; ?> When executing the commands directly within Unix, without the php script: 'which' yields 1 line: the path to the pear module for PHP 'locate' yields dozens of lines, paths to everything with 'pear' in it. However, this is the printout when running the script from a browser (same via command line) : --- which = /usr/local/bin/pear locate = /usr/ports/www/pear-HTTP_Upload/pkg-descr --- It's only printing out a single line for locate. I'm assuming i'd need to run a loop to read all the lines of locate from an array. My question is: what sort of general syntax can I use to get the results from locate stored in an array so it can be read out? I don't need a script written for me; a general nudge in the right direction or the right website would be incredibly helpful. I've had trouble finding anything relevant thus far.http://us4.php.net/manual/en/function.shell-exec.php -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com