Are there any potential pitfalls to be aware of when calling PHP scripts using the exec() function in a Linux environment?

When calling PHP scripts using the exec() function in a Linux environment, it's important to be cautious of potential security risks, such as command injection vulnerabilities. To mitigate this risk, always validate and sanitize any user input before passing it to the exec() function. Additionally, consider using escapeshellarg() or escapeshellcmd() functions to escape any user input to prevent shell injection attacks.

$user_input = $_POST['input'];
$validated_input = escapeshellarg($user_input);
exec("php script.php $validated_input");