[PHP] Re: exec problem
I'm getting a value of 0 returned, but from a command line the executable works fine and does what it is suposed to do is there any other way i can do this or ami i doing it work ?? Well, as far as I know, command-line returnes 0 on success and other on failure. So if your exec ( $command, $ValueIn, $ValueOut) returns 0 in $ValueOut it should be done correctly... Best regards Madsen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: exec problem
If it's internal stuff to your application, you can write in a 777 directory (such as /tmp) and retrieve it from there. If you want to write in a specific directory, you can set up a cron job to copy the file from the 777 directory to wherever you please from time to time. I'm not aware of any direct solutions to the problem (which is good - otherwise this posting would be renamed to Short Hacker's Guide to Arbitrarily Bypass Linux Permissions and thankfully that's not available). So you'll basically have to find a workaround with maximum functionality and minimum risks involved. Bogdan Xin Li wrote: Hi, I want to launch a program which writes a file on the server. But the process is under the owner of webuser who doesn't have write permission, and I don't want to set the directory writable to all users. I've searched the doc and tried every way but couldn't find a solution. Anybody knows how to solve this? BTW, my php is a pretty old version and doesn't support suexec and ftp functions. Thanks a lot Xin Li __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: exec problem
Hi I'm trying to create a script which my cron will run once a day to backup my MySQL database, but the exec command doesn't want to work no matter what I try... Uh. cron + PHP is cool, but using cron to run PHP to run mysqldump is kinda silly... :-) Just put the mysqldump line in your cron job, or create a shell script to do what you need. Basically, a shell script: 1. Starts with #!/usr/bin/sh (You can use any shell [bash, csh, ash, smrsh] instead of sh that feels good.] 2. Has stuff you would normally type on the command line, like: mysqldump -h localhost -u user -p pass --opt DataBase BACKUPS/backup.mysql 3. Has permission to be run by one or more users: chmod 700 backup.sh You can then use /path/to/backup.sh as a command, or use that in a cron job. exec(mysqldump -h localhost -u user -p pass --opt DataBase BACKUPS/backup.mysql) or die(Problem); I have tried adding the full path to mysqldump, You need that. I have tried using my root access, machine root, or MySQL root? The former is a BAD IDEA... The latter ain't so hot either. Certainly don't be putting a script with database passwords in your web-tree. I have tried using a different dir to store the files, changed permissions all sorts and nothing works. It always returns Problem and if I take out the or die then it just returns a blank screen. You can add more args to exec() to get more info about what went wrong/right: exec(..., $results, $errorcode); while (list(,$line) = each($results)){ echo $line, BR\n; } if ($errorcode){ echo OS Error: $errorcode. Usually paths/permissions. Use 'man errno' to look it up.BR\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Re: exec problem
if you have a shell account write a batch file and install it in the crontab of the user whihc mysql runs under. i did this at work for a postgresql database and it owrks perfectly. something like this will work. crontab -u user -e add: 30 7-19/2,23 * * * /backup/dumpit which runs /backup/dumpit every 2 hours at 30 mins past the hour between 7am and 7 pm and then again at 11 pm dumpit consists of: #!/bin/sh backdate=$(date +%Y%m%d%H%M.gz) /usr/local/pgsql/bin/pg_dump XXX | gzip /backup/edb-backup_$backdate cp /backup/edb-backup_$backdate /var/autofs/misc/ecalnet/ so i effect the file creates a file called edb-backup_date and time which is a zipped copy of the dump file. should be simple for you to substitute the mysql dump commands etc. Steve [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi I'm trying to create a script which my cron will run once a day to backup my MySQL database, but the exec command doesn't want to work no matter what I try... exec(mysqldump -h localhost -u user -p pass --opt DataBase BACKUPS/backup.mysql) or die(Problem); I have tried adding the full path to mysqldump, I have tried using my root access, I have tried using a different dir to store the files, changed permissions all sorts and nothing works. It always returns Problem and if I take out the or die then it just returns a blank screen. I also tried system () and that gave the same results. Anyone have any other ideas??? TIA __ -Ade ~~Good things come to those who wait~~ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]