Forum Moderators: coopster

Message Too Old, No Replies

shell_exec and variables

         

tekomp

12:28 am on Mar 12, 2006 (gmt 0)

10+ Year Member



I'm trying to execute a shell command within a loop to fetch a filename that is stored in an array, but it's not substituting the array with the contents of the array. Here's what I have:


for($i; $i<count($matches[1]); $i++)
{
`/usr/bin/fetch $matches[1][$i]`;
}

Outputs:


fetch: Array[0]: No such file or directory
fetch: Array[1]: No such file or directory

In this case, there are two files in the array, so I would need the script to fetch the files in $matches[1][0] and $matches[1][1].

Any ideas?

Thanks.

coopster

2:59 pm on Mar 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you tried dumping that variable to the browser first to be sure it is structured and contains what you think should be there, a string value representing a filename?
print '<pre>'; print_r($matches); print '</pre>'; exit; 
for($i; $i<count($matches[1]); $i++)
{
`/usr/bin/fetch $matches[1][$i]`;
}