I am trying to execute the following command with PHP.
Any one have a better suggestion or and idea why it does not work?
Looking at the error log doesn’t provide any useful info…
Command :
$pp = shell_exec(find /direcotry/*.jpg -maxdepth 1 -type f -print0 | xargs -0 ls -l | gawk '{sum += $5; n++;} END {print \"Total Size: \" sum/1024/1024 \" MB : Avg Size: \" sum/n/1024 \" KB : Total Files: \" n ;}';
Log :
[Mon Jan 28 11:08:27 2013] [error] [client X.X.X.X] PHP Parse error: syntax error, unexpected T_VAR in /var/www/html/report/functions/avgSize.php on line 15
you need quotes, and you forgot to close your call:
Also make sure the user that executes the script has permission to run find.