I'm coding a web interface to a horrible piece of propitiatory software our company uses. the software has no real UI and requires us giving putty access to our system for our clients to even pull data. My web interface has to run an exec(); function and it has to pass a few variables the user inputs.
$command = "report-call '$type' '$study' '$server' '$tag' '$specopt1' '$specopt2' '$specopt3' '$specopt4'";
$last_line = exec($command, $output, $returnvalue);
Now i assume i might be able to just remove any simicolins from the $command varible and be safe, but im not sure and thats why im posing this here before we go live next month.
What would be the best way to sanitize $command? There are a few special chars that I do need to be in the variables [ ] < > ! # $ .