Forum Moderators: coopster
<?php
$cmd1 = "/usr/bin/mysqldump -hsome.server.net -uusername -ppassword --all-databases > /home4/sub002/sc11883-LGVN/www/Backups/a.sql";
system($cmd1);
echo "Done";
?>
Look into the $ret value for the status code of the executed command. Additionally, system() returns the last line of the command output on success, and FALSE on failure.
$lastline = system($cmd, $ret);
echo "lastline $lastline, ret $ret\n";
If you need more output to diagnose your error, use the passthru() or exec() functions instead, where an array will returned with all output of the executed command.
Regards,
R.
Using the retval return code I get 127 and just a blank whitespace is printed for the $lastline.
I tried passthru() but get nothing. Is there an easy way to use exec() and echo out the array it creates?
[phpbuilder.com...]
The return code 127 could be a "program not found at this path" condition, or could be a result from a php safe_mode setting (don't have safe_mode here, so I can't help you here. Do a phpinfo() to see what you have).
A short look into the error_log would help here a lot.
I don't know, if a timeout would also generate a 127.
How long are you waiting until you see the 127 coming back?
To see the output of the exec(), try this:
exec($cmd,$array,$ret);
$output = join('<br>\n',$array);
echo $output;
Regards,
R.
Regards,
R.