>Hi!
>
>I've been using PHP to write shell scripts and was wondering how to
>implement the following:
>
> - I have a menuing system
> - If a user does not give an input within a certain amount of time, I want
>it to go to a default value
>
>I checked the PHP functions page and the closest thing I found was "sleep"
>which isn't quite right.  I'm sure this is a common thing, so does anyone
>have any suggestions?  Again, this is a terminal program and not a web CGI.

*MAYBE*, I say just *MAYBE* http://php.net/fgetc will time out and return
false if nothing is typed for "long enough"...  But that's probably "too
long" for what you need, and you have no control over it.

If you can somehow use fsockopen instead of a fopen, and "fool" that socket
into being a file using named pipes and redirect, you could *probably* do
much better by then setting the time-out on the socket...

>While I have your attention, I also wanted to create one of those "spinners"
>while users wait for longer tasks to complete.  I tried using the ncurses
>stuff to print and erase characters, but it didn't seem to work.  What is a
>good way to create a "spinner" so that users know that the program is
>working.
>
>For those who don't know what I mean, I'm thinking of something like...
>
>- (backspace) \ (backspace) | (backspace) / (backspace) etc. etc.

Wild Guess:

<?php
  $beach_ball = array('-', '\', '|', '/');
  $file = fopen('php://stdout', 'w') or die("Could not open stdout");
  for ($i = 0; $i < 80; $i++){
    echo $i, chr(8); # 8 is ^H, right?
  }
?>

-- 
Like Music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to