vks_foe Posted June 14, 2011 Share Posted June 14, 2011 Hi friends, i have an executable made from c code which i call in my php script using exec. The code uses scanf to get input from stdin. But when call this from my webpage, the scanf part is ignored and some junk values are assumed. Is there any means to provide runtime inputs/values to the executable, when called using exec, system, etc in phpscript?? Quote Link to comment https://forums.phpfreaks.com/topic/239337-integrating-c-in-php-scanf-and-printf/ Share on other sites More sharing options...
AbraCadaver Posted June 14, 2011 Share Posted June 14, 2011 You could try something like: exec("echo 'what ever you want to stdin' | /path/to/bin/prog"); If not, proc_open() should do it but will take some study. Quote Link to comment https://forums.phpfreaks.com/topic/239337-integrating-c-in-php-scanf-and-printf/#findComment-1229531 Share on other sites More sharing options...
AbraCadaver Posted June 14, 2011 Share Posted June 14, 2011 Oh, and scanf() probably needs a newline, so: exec("echo -e 'what ever you want to stdin\n' | /path/to/bin/prog"); Quote Link to comment https://forums.phpfreaks.com/topic/239337-integrating-c-in-php-scanf-and-printf/#findComment-1229534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.