You are here: Re: [PHP] Simple Question: Reading exec(locate) results into an array « PHP « IT news, forums, messages
Re: [PHP] Simple Question: Reading exec(locate) results into an array

Posted by John Nichel on 04/27/05 23:46

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация