Welcome! Log In Create A New Profile

Advanced

[PHP] cli script

Posted by Jeffry Killen 
Jeffry Killen
[PHP] cli script
January 15, 2018 02:50AM
Hello;

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?

Thanks for time and attention;
Jeff K

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Yeni Setiawan
Re: [PHP] cli script
January 15, 2018 02:50AM
Hi Jeff,

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.

On Mon, Jan 15, 2018 at 8:40 AM, Jeffry Killen <[email protected]> wrote:

> Hello;
>
> 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?
>
> Thanks for time and attention;
> Jeff K
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
regards,

Yeni Setiawan
http://sandalian.com
Aziz Saleh
Re: [PHP] cli script
January 15, 2018 03:10AM
On Sun, Jan 14, 2018 at 8:47 PM, Yeni Setiawan <[email protected]>
wrote:

> Hi Jeff,
>
> 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.
>
> On Mon, Jan 15, 2018 at 8:40 AM, Jeffry Killen <[email protected]>
> wrote:
>
> > Hello;
> >
> > 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?
> >
> > Thanks for time and attention;
> > Jeff K
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> regards,
>
> Yeni Setiawan
> http://sandalian.com
>

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.
Jeffry Killen
Re: [PHP] cli script
January 15, 2018 03:10AM
> On Jan 14, 2018, at 6:00 PM, Aziz Saleh <[email protected]> wrote:
>
> On Sun, Jan 14, 2018 at 8:47 PM, Yeni Setiawan <[email protected]>
> wrote:
>
>> Hi Jeff,
>>
>> 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.
>>
>> On Mon, Jan 15, 2018 at 8:40 AM, Jeffry Killen <[email protected]>
>> wrote:
>>
>>> Hello;
>>>
>>> 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?
>>>
>>> Thanks for time and attention;
>>> Jeff K
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>>
>> --
>> regards,
>>
>> Yeni Setiawan
>> http://sandalian.com
>>
>
> 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.

I should have included that:
#!/usr/bin/php -f
<?php // ... etc ?>

.... O.K. this may not be the location of the php executable on Mac OSX.
I think I may have originally written it for a server on a FreeBSD system.

Thank you for time and attention
Jeff K


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jeffry Killen
Re: [PHP] cli script
January 15, 2018 03:20AM
> On Jan 14, 2018, at 5:47 PM, Yeni Setiawan <[email protected]> wrote:
>
> Hi Jeff,
>
> 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.
>
> On Mon, Jan 15, 2018 at 8:40 AM, Jeffry Killen <[email protected]> wrote:
>
>> Hello;
>>
>> 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?
>>
>> Thanks for time and attention;
>> Jeff K
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> regards,
>
> Yeni Setiawan
> http://sandalian.com


Yes... yes... Yeni Setiawan: ./BTO.php
I forgot about that. Thanks
So, now I am getting errors from script so I know its running
and can shake out the bugs.


JK


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Paul M Foster
Re: [PHP] cli script
January 15, 2018 07:50AM
On Sun, Jan 14, 2018 at 06:08:33PM -0800, Jeffry Killen wrote:

>
> > On Jan 14, 2018, at 6:00 PM, Aziz Saleh <[email protected]> wrote:
> >
> > On Sun, Jan 14, 2018 at 8:47 PM, Yeni Setiawan <[email protected]>
> > wrote:

[snip]

> >
> > 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.
>
> I should have included that:
> #!/usr/bin/php -f
> <?php // ... etc ?>
>

This might be better handled with the following:

#!/usr/bin/env php
<?php

This is, as I recall, the way the python folks do it.

Paul

--
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Sorry, only registered users may post in this forum.

Click here to login