|
Posted by Karl Fry on 04/27/05 23:25
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.
Thanks!
-Karl
Navigation:
[Reply to this message]
|