Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have this PHP script:

<?php

$od = shell_exec('od /dev/hwrng --address-radix=n --read-bytes=4 --format=u4');

?>

<html>

<head>
<title>hwrng</title>
</head>

<body>

<?php echo $od; ?>

</body>

</html>

The bash command works as expected when I'm in the shell, but not when called inside PHP through shell_exec(), infact it doesn't produce any output. I noticed that replacing /dev/hwrng with /dev/random solves the problem, however I really need to use /dev/hwrng in my script, but I can't figure out what's wrong. Thanks for helping!

share|improve this question

1 Answer 1

Sorry for posting, I found a solution by myself. I found that it was a problem with permissions, so I added 'sudo' to the bash command, and I edited /etc/sudoers adding the user 'www-data' (the default nginx user) with 'NOPASSWD' parameter. I hope it could be useful for those having the same problem.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.