Page 1 of 1

system() won't work status return 2

Posted: Sun Sep 14, 2014 2:39 pm
by pizzipie
I can substitue values for the variables '$database' and '$filename' below and run from the command line - Works just fine.

This will return 2 and not work when run programetically. All files accessed have chmod 777.

Please ! How to fix ????

Code: Select all

$command ="/usr/bin/mysqldump --host='localhost' --user='rick' --password='rick' --add-drop-database --databases ".$database. " | gzip > " .$filename;

$bak_result = system($command, $retval);
// returns 2

Re: system() won't work status return 2

Posted: Sun Sep 14, 2014 4:57 pm
by requinix
If you output $command and run it yourself, does it work?
You have output redirection which means it will try to create a file - are permissions set up correctly for the containing directory?
Try a different command from system(), one that will let you capture stdout and stderr, and check those for error messages.

Re: system() won't work status return 2

Posted: Sun Sep 14, 2014 6:08 pm
by pizzipie
Thanks,

I left out permissions for 'other' to write to.

Now it works!