system() won't work status return 2

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pizzipie
Forum Commoner
Posts: 87
Joined: Wed Feb 10, 2010 10:59 pm
Location: Hayden. ID

system() won't work status return 2

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
pizzipie
Forum Commoner
Posts: 87
Joined: Wed Feb 10, 2010 10:59 pm
Location: Hayden. ID

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

Post by pizzipie »

Thanks,

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

Now it works!
Post Reply