I have a small foreach loop in php but the results will not pass to a shell script. see below:
$contents = file("$target_dir/$user.temp.txt");
foreach($contents as $line) {
echo $line . "<br />";
exec("sh read.sh $line >> tempfile");
}
the echo statement works just fine and displays the data to screen as it should. however the result of $line does not make it to the shell script, but when I replace $line with a random string it does. here is the shell script:
#!/bin/bash
#test script
echo "test output: $1"
when trying to call the shell script with $line in place, the tempfile will get created but is blank. all my permissions are set to 777 and the group calling the script is the same owner as the folder. I've reviewed other posts about php loops but dont seem to find anything that matches exactly what my issue is.
Thanks in advance for any insight.
$line?exec("sh read.sh '$line' >> tempfile");