What potential issues can arise when using the exec function in PHP for system commands on a Raspberry Pi?
When using the exec function in PHP for system commands on a Raspberry Pi, potential issues can arise with security vulnerabilities if user input is not properly sanitized. To prevent this, always validate and sanitize user input before passing it to the exec function to avoid command injection attacks.
$user_input = $_POST['input']; // Assuming user input is coming from a form
// Sanitize user input using escapeshellarg function
$sanitized_input = escapeshellarg($user_input);
// Execute the command with sanitized input
exec("command " . $sanitized_input);