How to get errors from exec?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D. Alvarado

    #1

    How to get errors from exec?

    Hello,
    I am running PHP 4 and this code is failing, in that it does not
    insert the records into MySQL

    // Upload the data to file to the db.
    exec("mysqlimpo rt --replace --fields-terminated-by=','
    --fields-optionally-enclosed-by='\"' --user=$db_user
    --password=$db_pa ssword --host=$db_hostna me
    --lines-terminated-by='\\r\\n' $db_name $new_src_file_p ath", $output,
    $return);

    Sadly, the $output array is empty, but the $return value is 127. Does
    anyone know what that means or how I can get more meaningful error
    output?

    Thanks in advance, - Dave
  • Shane Lahey

    #2
    Re: How to get errors from exec?

    On 26 May 2004 07:57:26 -0700, laredotornado@z ipmail.com (D. Alvarado)
    wrote:
    [color=blue]
    >Hello,
    > I am running PHP 4 and this code is failing, in that it does not
    >insert the records into MySQL
    >
    > // Upload the data to file to the db.
    > exec("mysqlimpo rt --replace --fields-terminated-by=','
    >--fields-optionally-enclosed-by='\"' --user=$db_user
    >--password=$db_pa ssword --host=$db_hostna me
    >--lines-terminated-by='\\r\\n' $db_name $new_src_file_p ath", $output,
    >$return);
    >
    >Sadly, the $output array is empty, but the $return value is 127. Does
    >anyone know what that means or how I can get more meaningful error
    >output?
    >
    >Thanks in advance, - Dave[/color]


    you could try adding 2>&1 to the end of the command so all command
    output goes to stdout.....

    example:

    exec('df -h 2>&1', $output, $retcode);
    if ($retcode != 0)
    {
    printf("Error executing command:\n");
    echo $output . "\n";
    exit;
    }

    Comment

    Working...