> Unfortunately, since they are coming in through a socket and not actual > telnet/ssh I don't think $fp=fopen("/dev/stdin", "r"); works? Isn't that > only for terminal based input? > > Donald Myers
oops... forgot this: http://www.php.net/manual/en/ref.pcntl.php Jim Grill > > > on 9/2/04 10:31 AM, Jim Grill at [EMAIL PROTECTED] wrote: > > >> Hello, I have been banging my head trying to figure out how to design a > > MUD > >> Server using PHP-CLI as the server and PHP-CLI as the "command" language. > >> (telnet front end at this point) > >> > >> but.... > >> > >> The real problem is full interaction with the user in those external > >> commands (php-cli scripts) to send and read data. > >> > >> > >> A. How do I create a input method to connect the external PHP script to > > the > >> Server's Socket? > >> > >> B. Since the PHP-CLI script never ends how can I send the first echo "You > >> have..."? > >> D Myers > >> > > > > I hope I'm understanding what you're asking. If you need to interact with > > the user via stdin you can use this function to capture user input: > > > > function read() > > { > > $fp=fopen("/dev/stdin", "r"); > > $input=fgets($fp, 255); > > fclose($fp); > > > > return $input; > > } > > > > Your code flow could look something like: > > <?php > > do { > > print "what's your name?\n"; > > $name = read(); > > } while (empty($name)); > > > > print "Hello $name!\n"; > > sleep(1); > > > > do { > > print "What is your jedi name?\n"; > > $jediName = read(); > > } while (empty($jediName)); > > > > print "Hello $name AKA $jediName\n\n"; > > > > function read() > > { > > $fp=fopen("/dev/stdin", "r"); > > $input=fgets($fp, 255); > > fclose($fp); > > > > return trim($input); > > } > > ?> > > > > I hope that gets you started in the right direction. Sounds like a fun > > project. > > > > Jim Grill > > Web-1 Hosting, LP > > http://www.web-1hosting.net > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php