Hello, is it possible to open a stream in which I can write commands and read output from them to a shell like bash? I want to do this because this program can not be completed with just a `backtick` or shell_exec() command, as it's somewhat user-interactive.
As an example, let's say I want to get cdecl to explain to me what "char *horse" means. I would type: # <i>cdecl</i> Type `help' or `?' for help cdecl> <i>explain char *horse</i> declare horse as pointer to char cdecl> <i>exit</i> ...where input is surrounded by <i>these</i>. This would be difficult or impossible to do with shell_exec, especially if halfway-through you have to do some calculating before you can know what to ask cdecl next. So I want to know whether you can somehow open a stream to a shell, and execute commands there. Like... $fp = fopen('/bin/bash', 'rw'); $output = fgets($fp); fputs($fp, 'cdecl'); $output = fgets($fp); $output = fgets($fp); fputs($fp, 'explain char *horse'); $expl = fgets($fp); /* Right now you could do some calculations and figure out what to do next. */ $output = fgets($fp); fputs($fp, 'exit'); $output = fgets($fp); fclose($fp); Now this obviously wouldn't work, as it would overwrite the bash executable if you had proper access, but it's just to get the idea across. So, does anyone know how I can do this? -- Joel Kitching http://midgardmanga.keenspace.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php