Have a look at exec
You could use shell_exec():
$cmd = sprintf("keygen AB3554C1D1971DB7 %s 365",
escapeshellarg($pccode));
$result = shell_exec($cmd);
Whenever you execute external commands you have to be extremely careful to avoid command injection. You can prevent this using escapeshellarg().
It could be that this program is poorly written and outputs its information to stderr instead of stdout. Or it could be that it is failing and (properly) printing the error message to stderr. In either case, shell_exec wouldn't capture stderr. However, you should be able to capture stderr by adding "2>&1
" to the end of your command, i.e.:
$result = shell_exec('keygen AB3554C1D1971DB7 \pc_code 365 2>&1');
echo '<pre>'.htmlspecialchars($result).'</pre>';
Edit: For continuity's sake, what fixed the problem was something mentioned in a comment to another answer below:
Maybe it doesn't like the bare backslash? you could try "
\\pc_code
"
Executing a Linux command isn't really possible from JavaScript (nor should it be). Assuming you're referring to JavaScript that is run on a client's web browser, there would be no security model that would keep people safe from malicious command line access. PHP is a different story.