I have a php script which is doing the following job.
$unTarCommand = 'tar -zxvf test.tar.gz';
$tarOutput = shell_exec($unTarCommand);
The code is working fine. Now the problem is when i am running the tar lists all files and it will get assigned to $tarOutput. So i am not able to identify whether tar runs without any error or not. Is there anyway to capture only the error in $tarOutput variable.
This code is part of a cron job.
Instead of
shell_exec(), use theexecfunction:The output assigned to a variable passed to the function, and the function’s return value is what you need.