In cases where shell_exec does not produce the expected output, what troubleshooting steps can be taken to identify and resolve the issue, especially when the command works directly in the SSH command line?

If shell_exec does not produce the expected output even though the command works directly in the SSH command line, the issue may be related to the environment in which the PHP script is running. To troubleshoot this, you can try specifying the full path to the command being executed in shell_exec or setting the PATH environment variable explicitly in your PHP script.

putenv("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin");
$output = shell_exec("/full/path/to/your/command");
echo $output;