Thanks for pointing me in the right direction. Could not get the output
(success or failure) assigned to a variable in front of the system call but
got it to assign a 0 (success) or 1 (failure) to the return_var argument as
you suggested so I am happy.


system("mysql -u myuserid -pmypassword mydbname < /path/to/mydumpfile.txt",

if($status == 1){
echo 'Failed';
} else {
echo 'Success';


What mixed me up and I still don't understand is the manual entry for
system() says ...

"Returns the last line of the command output on success, and FALSE on

When it says it "Returns", where does it return this information and how can
it be captured for comparison? The return_var appears to only return a 0 or
a 1. I thought I could capture it by assigning the system call to a variable
in front but that appears to capture nothing on success or failure.

"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
> On Tue, Jul 09, 2002 at 10:59:04PM -0700, Fargo Lee wrote:
> >
> > Thanks but it still returns "Success" on a failure. If anyone knows if
it is
> > even possible to assign the output of system, passthru or exec to a
> > to check for success or failure and how to do it, please advise. The
> > variable seems to always be empty on success or failure when I try to
> > it.
> The way you set things up, $status is the last line of text returned by
> executing the command.  Add the return_var argument to your system()
> statement.  Take a look at the manual again.
> You can only make an accurate if() statement if you know what the values
> are you're expecting.
> Now, do some hacking.  Set up the test to fail.  Echo $status and $return
> to the screen and see what they look like.  Set up the test to succeed.
> What do $status and $return look like then?
> --Dan
> --
>                PHP classes that make web design easier
>         SQL Solution  |   Layout Solution   |  Form Solution
>  | |
>  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>  4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to