Page 1 of 1

problem with system call function

Posted: Sat Nov 06, 2004 12:36 am
by murthy
Hi,

I am executing system call function in the loop ..But i am getting last statement of the result only.

for example:

for($i=0;$i<count($splitfile);$i++){
$hinfo=system("cat /home/flatmonk/www/Data/Lists/".
escapeshellarg($splitfile[$i]),$retvalue);
if($hinfo)
echo $retvalue.'<br>';
}

I am getting last result only......

Thanks,
Murthy

Posted: Sat Nov 06, 2004 3:33 am
by swdev
I am not sure what you are saying.

Are you saying that you only get the last line from the last file in the $splitfile array or are you saying that you only get the last line from each file in the $splitfile array.

if the latter, then this is how the [php_man]system[/php_man] function works.

If you want to read the complete contents of a file, then use [php_man]file_get_contents[/php_man] or [php_man]fread[/php_man] and its cousins.

Hope this helps.

Posted: Sat Nov 06, 2004 8:03 am
by John Cartwright
I would generally use file_get_contents because it does fopen and its `cousins` in one blow