top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Run PHP cli script as root?

0 votes
48 views

I have a cli script and I want to run it as root.

So I run "sh-3.2#BTO.php" when pwd is the directory containing the BTO.php script file.

The cli script resides in a server document root dir. It is for changing ownership to server user for specific named files.

I am informed that "BTO.php: command not found"

I don't do this often enough to be on top of the problem/solution

But I don't remember having this problem in the past. I have copied the document root dir and contents and installed the copies in another servers document root. Then I run this cli as root to change all the permissions to server user on new server.

There are no phantom spaces in the name and O is not 0 (zero) in the name, or vis versa.

Any other possibilities?

posted Jan 15, 2018 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

0 votes

Have you chmod-ed your cli script into executable? (chmod +x filename.php).

After chmod it, you can call it by using command like:

server# ./BTO.php

Don't forget to add shebang line on your cli file that refer to php executable file location.

answer Jan 15, 2018 by Sanketi Garg
0 votes

What is your first line of the PHP file? Does it contain the location to PHP executable binary (ex: #!/usr/bin/php)? If not you would need to run the php file as /usr/bin/php BTO.php.

answer Jan 15, 2018 by Jagan Mishra
0 votes

Hii,

To run php cli script as root...u have to add your scrpit into chmod-ed to executable.

After that you can used command like:

server# .BTO.php
answer Sep 25 by Siddhi Patel
Similar Questions
+1 vote

I want to code a member area script for processing activities between members of my website i.e. sending and receiving messages between logged in members. Any suggestions?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...