I think shell_exec() doesn't return the actual result of executed command, only -1 if it failed and 0 if it succeeded. So something like shell_exec('ls -al') won't retrieve list of files. You could make a bash script that writes the list of all files in specified folder to a txt file which you could then read through ScriptCore. Only I'm not sure if you can run a bash script with shell_exec().