FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Only Allow exec in CLI
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Only Allow exec in CLI [message #179196 is a reply to message #179194] Tue, 25 September 2012 11:27 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
crankypuss wrote:
> On 09/25/2012 04:00 AM, The Natural Philosopher wrote:
>> crankypuss wrote:
>>> On 09/24/2012 06:54 AM, The Natural Philosopher wrote:
>>>> Tim Streater wrote:
>>>> > In article <k3ph16$7ur$5(at)news(dot)albasani(dot)net>,
>>>> > The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>>> >
>>>> >> M. Strobel wrote:
>>>> >> > Am 24.09.2012 01:14, schrieb cph:
>>>> >> >> For security I am looking to add exec() and similar commands to
>>>> >> the >> disable functions >> setting in php.ini but I do have a need
>>>> >> to execute command line commands >> within a cron job I am writing in
>>>> >> PHP.
>>>> >> > > The answer is highly dependent on your system setup, as has been
>>>> >> said > already. I would start with a check to see if different .ini
>>>> >> files
>>>> >> > for web server and CLI are in place already.
>>>> >
>>>> >> I cant imagine why anyone would put PHP in a cron job to start with.
>>>> >>
>>>> >> Shell script or C, or both...
>>>> >
>>>> > Neither. PHP is a lot easier to write and I can't see that there's
>>>> > going to be a great deal that you can't do in PHP that you can with
>>>> > the others. Unless you need every last CPU cycle of course.
>>>> >
>>>> Actually there is a very great deal you can do in C that you cant do in
>>>> PHP.
>>>>
>>>> Multitasking for one thing.
>>>
>>> I find PHP to be an order of magnitude more capable than shell
>>> scripting.
>>>
>>> http://php.net/manual/en/function.pcntl-fork.php
>>>
>>
>> yebbut when you have 5 C programs you want to run one after another,
>> creating a php wrapper is overkill.
>
> If all the arguments are constants, a shell script might do the job as
> long as you don't bother checking results. It seems that "modern"
> programmers don't need to check for unusual conditions because of their
> godlike programming prowess, but being an old-school geezer it's a
> longstanding habit I'm unable to discard as a result of lacking the
> godlike wisdom of newbies.
>
> The minute you start attempting to parse arguments or do anything else
> in shell scripts you are resorting to sed or awk or whatever and just
> doing a simple strpos() becomes a nightmare.
>
> Do whatever suits you, I find that in general shell scripts are for
> "ineptocrats" who don't care about error checking and the associated logic.
>
> The overhead for a php "script" is trivial:
>
> #!/usr/bin/php
> <?php
> // ini_set('include_path', '/usr/lib/php-local');
> // include_once 'includes_cli-app.php';
> ?>
>
> Of course the ini_set and include_once lines are optional for use by
> those of us who practice code reuse in addition to other practices like
> error checking (and most systems don't have a /usr/lib/php-local). Many
> of the subroutines I use in PHP "scripts" are also used by PHP
> page-generation code, and most will operate under Windows or Linux.
>
> That means the "wrapper" addition for PHP over and above what would be
> needed for a "shell script" amounts to the "<?php" and "?>" lines. For
> that you get to use a programming language instead of a script
> abomination; mileage varies, obviously.
>
Mo. I still have to write all the exec() calls.

Consider the case. I have 4 programs I want to run serially under a
cron script

I set up the script like this

#!/bin/sh
program1
program2
program3
program4


Now tell me what else I have to add to make that run under php.


Or why on earth I would want to.



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Advice for Literature on PHP-Based Web Development Business Models
Next Topic: Count how many times a value occurs in an array
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 22:42:28 GMT 2024

Total time taken to generate the page: 0.03872 seconds