I want to use s3cmd
from my PHP script. Everything is working from shell but same not working from my PHP script.
shell_exec('s3cmd --config=/root/s3cmd.conf ls');
this is not working, and then i gave full path to my s3cmd installation
shell_exec('/usr/sbin/s3cmd --config=/root/s3cmd.conf ls');
Not working in PHP script but the same is working in command,
The PHP file which is calling the shell_exec is in webroot.
Might be the problem that s3cmd is configured as a root user and i am running from PHP which is www-data. if this is the problem how can i create config file for www-data.
Help me what i am doing wrong.
Thanks
EDIT I am using S3cmd. To run commands in my cron script. cron Script is a PHP script. The user running the cron is web11 and the s3cmd is configured using the root user.
so when i run s3cmd using shell_exec() in my PHP script it fails. But when i run in shell it works fine.
s3cmd ls
This works fine. as i am login using root user.
i tried to run it using runuser command
runuser -l root -c "s3cmd ls"
This works fine and displays list of buckets. But when i run using
runuser -l root -c "s3cmd ls"
This does not work. I tried by giving full path of the s3cmd
/usr/bin/s3cmd ls
this works in shell but not in my PHP script.
I changed permissions 777 for the php script and made root the owner of that user. but still does not work.
How can i run s3cmd from PHP script. ? i am on amazon Ec2 Instance.