problem with system call function

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
murthy
Forum Commoner
Posts: 50
Joined: Fri Aug 20, 2004 1:22 am
Location: India
Contact:

problem with system call function

Post 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
swdev
Forum Commoner
Posts: 59
Joined: Mon Oct 25, 2004 8:04 am

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I would generally use file_get_contents because it does fopen and its `cousins` in one blow
Post Reply