Link to home
Start Free TrialLog in
Avatar of Starquest321
Starquest321

asked on

PHP Script

On a CENT OS box 7:

I have a script that when I run from the SSH works perfects...but running from a browser or cron does not work. I get the following error:

When i run my php page in Browser getting the following error ::

Warning: fopen(property.csv): failed to open stream: Permission denied in /var/www/html/*****/download.php on line 44

Unable to create property.csv ..


I run the same page in SSH :: Using Following command

php /var/www/html/*****/download.php

It run perfectly .. and created csv file.. But not working when i run this page in browser or cron
SOLUTION
Avatar of Radek Baranowski
Radek Baranowski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Starquest321
Starquest321

ASKER

vimalmaria:
(1) What command steps in detail can I take to check for option 1.
(2) I have given the folder and file ALL permissions. So how is that possible?
if all permissions are desired enter chmod filename/folder -R 777

where chmod is command to set permissions
filename/folder is desired object to set permissions on
-R sets permissions recursively (on all child objects / sub folders and files)
777 = permissions full read, write, and execute for current user, all users, and admin users
Radek Baranowski: I ran the user and this is the result I get:
ps -ef | grep httpd
root      1073     1  0 Sep13 ?        00:00:12 /usr/sbin/httpd -DFOREGROUND
apache   11236  1073  0 03:22 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11256  1073  0 03:22 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11257  1073  0 03:22 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11258  1073  0 03:22 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11259  1073  0 03:22 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11272  1073  0 03:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11274  1073  0 03:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11275  1073  0 03:27 ?        00:00:01 /usr/sbin/httpd -DFOREGROUND
apache   11276  1073  0 03:27 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11464  1073  0 03:58 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache   11465  1073  0 03:58 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
root     12813 12782  0 12:11 pts/0    00:00:00 grep --color=auto httpd

In the folder. . . this is the permissions:
folder:
drwxrwxrwx. 2 root root   4096 Sep 15 03:58 rets

In the file:
-rwxrwxrwx. 1 root root  3412 Sep 15 04:33 download.php
The simply issue: When I run the page in putty its runnign perfect. But in browser giving this error:

Warning: fopen(property_res.csv): failed to open stream: Permission denied in /var/www/html/application/download.php on line 44

I have given all permissions to folder rets .. still no luck...
09 * * * * root /var/www/html/applicationrets/download.php

Tried a full path as well.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes . .using W+.
It will be an empty file and we will start writing to that file.  If the file does not exist it will create.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
even if I give user:: group as root I still have the same issue. Coult it be that first issue with htaccess?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The only logical question I have: Why would it work from SSH? That does not make sense. If the script is broken . . how will it allow itself to run from anywhere. . .
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I also don't believe the script is broken. It works fine. Right now I can make the owner :: group - root or apache....just stuck here. What to do?

Script works perfect when logged in as root and using SSH
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The trouble area:


            echo "+ {$resource}:{$class}<br>\n";

        $file_name = strtolower("{$resource}_{$class}.csv");
        $fh = fopen($file_name, "w+");


        $maxrows = true;
        $offset = 1;
        $limit = 50;
        $fields_order = array();
                        
            $i=1;
Warning: fopen(property.csv): failed to open stream: Permission denied in /var/www/html/application/rets/download.php on line 44
Array
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are these settings under php.ini?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial