Well that certainly runs them one after the other but it doesn't stop for
text input. It Just stops all together?

Filename: tester.php
#!/usr/local/bin/php -q
<?php
set_time_limit(0);
ob_end_flush();

function input($prompt = null) {
    if ($prompt != null) print $prompt;

    $fp=fopen("/dev/stdin", "r");
    $input=fgets($fp, 255);
    fclose($fp);
    
    return rtrim($input,chr(10));
}

print "start program 1\n";

$inp = input("filename ");
print "you typed ".$inp;

system("/usr/local/bin/php -f ./hello.php")

print "end program 1\n";
?>

Filename: hello.php
#!/usr/local/bin/php -q
<?
set_time_limit(0);
ob_end_flush();

function input($prompt = null) {
    if ($prompt != null) print $prompt;

    $fp=fopen("/dev/stdin", "r");
    $input=fgets($fp, 255);
    fclose($fp);
    
    return rtrim($input,chr(10));
}

$name = input("what's your name? ");

print "Hello $name!\n";
?>

Is my input function no good?

Don Myers


on 9/16/04 5:39 PM, Greg Donald at [EMAIL PROTECTED] wrote:

> On Thu, 16 Sep 2004 16:40:13 -0400, Don Myers <[EMAIL PROTECTED]> wrote:
>> All, I have a PHP Command Line Interface (CLI) script which uses stdin and
>> stdout for reading and writing to/from the terminal.  Now I need to have
>> that script open another PHP-CLI script which ALSO needs to uses stdin and
>> stdout for reading and writing to/from the terminal. This script may in turn
>> open another... and another.... Of course after the script ends it returns
>> to the line in the script that called it and so on. Until it's "done"
>> 
>> I am writing a bunch of PHP-CLI scripts which open other helper PHP-CLI
>> scripts which may be called together or apart (so includes don't work)
> 
> 
>> cat first.php second.php third.php
> #!/usr/bin/php
> <?php
> echo "I am first.php\n";
> system('/usr/bin/php -f ./second.php');
> ?>
> 
> #!/usr/bin/php
> <?php
> echo "I am second.php\n";
> system("/usr/bin/php -f ./third.php");
> ?>
> 
> #!/usr/bin/php
> <?php
> echo "I am third.php\n";
> ?>
> 
>> ./first.php
> I am first.php
> I am second.php
> I am third.php
> 
> 
> -- 
> Greg Donald
> http://gdconsultants.com/
> http://destiney.com/
> 
> -- 
> 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

Reply via email to