The problem is that exec() is looking for an immediate output and since I am
calling a command line program it doesn't return fast enough for it (I
think).  The popen or fopen looks like it would work, but I don't understand
how to execute the command.  Ie.
<?php

$cmd = "ls -la"

$lines = file ($printers);
while (list ($line_num, $line) = each ($lines)) {
    $trimline = trim ($line);
    $fp = popen ("$cmd", "r");
    exec($fp)
    echo "npadmin output: $output\n";
    pclose ($fp);
}
?>


 -----Original Message-----
From:   Rick Emery [mailto:[EMAIL PROTECTED]] 
Sent:   Monday, March 25, 2002 4:30 PM
To:     'Darren Gamble'; 'Walker, Roy'; '[EMAIL PROTECTED]'
Subject:        RE: [PHP] Regular Expressions?  Help!

exec() can capture ALL output from a command if you supply an array as the
second argument to it

-----Original Message-----
From: Darren Gamble [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 3:58 PM
To: 'Walker, Roy'; '[EMAIL PROTECTED]'
Subject: RE: [PHP] Regular Expressions? Help!


Good day,

exec() isn't very good at capturing output.  It will only return the last
line of output, which is designed mostly to capture error conditions.

You would be best off using popen() and attaching a pipe to the output, and
then just read from the pipe.  More information can be found about popen()
with PHP's documentation.

Try that instead.

============================
Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948


-----Original Message-----
From: Walker, Roy [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 25, 2002 12:26 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] Regular Expressions? Help!


I am trying to do a match for an expression and it to a variable from the
output of a command: 

<?php

$lines = file ($file);
while (list ($line_num, $line) = each ($lines)) {
    $trimline = trim ($line);
    $output = shell_exec ("$prog $cmdline $trimline &");
}
?>

How can look through $output to set the information returned as different
variables the output would look like:
variable1:"some information" variable2:"some information"

I want to set each variable to a string and write it to a file.

Thank You for you help.
Roy


************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above.  If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you. 


-- 
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


************************** PLEASE NOTE **************************
This E-Mail/telefax message and any documents accompanying this transmission
may contain privileged and/or confidential information and is intended
solely for the addressee(s) named above.  If you are not the intended
addressee/recipient, you are hereby notified that any use of, disclosure,
copying, distribution, or reliance on the contents of this E-Mail/telefax
information is strictly prohibited and may result in legal action against
you. Please reply to the sender advising of the error in transmission and
immediately delete/destroy the message and any accompanying documents.
Thank you. 


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

Reply via email to