After executing
frama-c -pdg -dot-pdg graph -pdg-print test.c
in a shell_script through php file. I am getting output as permission denied for graph.main.dot while directly executing the above command I am getting correct output.
Because when you run it, you are running it from your user account, and when PHP runs it, it is running it from the webserver account.
You have permission to access graph.main.dot but the web server does not.
You can alter the permissions using the chmod and chgrp commands.
Related
This is my command that I've made but I get an error , I'm on WIN10
The error says that the user account that tries to run the command on that system has not the permissions / rights to do so. Please check, what user is trying to run that command and either give appropriate rights or create / change the permissions on that file.
I am trying to rsync file from local to remote server.
When i do this on console it works:
rsync -avzhe ssh /var/www/folder1/file5
root#192.168.56.74:/var/www/folder2
but when i do this on my php and run the php script, it doesn't work:
$rysncCommand = "rsync -avzhe ssh /var/www/folder1/file5 root#192.168.56.74:/var/www/folder2";
shell_exec($rysncCommand);
There is no error shown, so i can't really tell what is the error. Is there something wrong with my php script?
First, you need to check if you need to be a root or (sudo user) for running rsync.
If yes then exec() command will only work if it is run by same user on php-cli (not on browser by Apache user). i.e. Which user you are loggined into shell for run rsync.
If it is root or any elavated permission user with sudo permission then, This rsync command may not be available to apache/www-data user which is working when php script run from browser.
So You try to make a normal user and login through it, Then try rsync if you are successful then it may be interesting to see what are other problems can be, But if you getting access/permission denied then obviously you can not run this script at-least on browser.
Besides this One more thing permission may not be directly related to rsync command itself but with folder /etc/test/ which is owned by root user in normal scenario.
For more details you can check this Stack Overflow Link .
I am trying to execute a shell command from php command line in following way
php -r '$test = exec("aws s3 cp s3://test/my-container/testing.txt /var/www/files-test"); echo $test;'
this works and as result files get downloaded from s3 to mentioned destination /var/www/files-test
But when I execute same command from web app it does not work. Code is
$test = exec("aws s3 cp s3://test/my-container/testing.txt /var/www/files-test");
print_r($test);
it does not work and as output I got
Completed 1 part(s) with ... file(s) remaining
I have ensured apache user has required privileges. What can be missing here?
I got this resolved, web-server I am using was nginix and web app some how was running on apache user, I gave permissions for nginix user but not for apache user!
so fix was to get back the app to run on nginix user.
I am trying to run php script via execute shell in Jenkins but it seems i am missing something.
here is my command in execute shell of Jenkins
#!/usr/bin/php
php /home/admin/reports/test.php"
I am not getting any error in console output.
and when i try these commands:
#!/bin/bash
php /home/admin/reports/test.php"
then I get error which says failed to open stream: Permission denied in /home/admin/reports/test.php" .
Jenkins, with default installation, will be run under jenkins user. That user has no access to your /home/admin home directory. The Permission denied is pretty self-explanatory.
Either give jenkins user read access to /home/admin (not recommended)
Or place the file into /home/jenkins directory (not best solution either)
Or better yet, have the file available in shared location accessible by both, preferably the job's workspace that is populated through the SCM (recommended).
i'm having this problem
sh: CutyCapt: Permission denied
my php code is
<?php
echo exec('CutyCapt --url=http://www.google.com --out=/var/www/google.png --javascript=on 2>&1');
?>
When calling an executable from PHP, it is called with the permissions of the user PHP runs as (often the Apache server, for example).
That user account does not have permission to call that executable - probably because it belongs to a different user, and has the "executable" bit only for that user or group.
That's all that can be said for sure without more information.