Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7128

Re: Only Allow exec in CLI

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Only Allow exec in CLI
Date 2012-09-25 07:45 -0400
Organization A noiseless patient Spider
Message-ID <k3s5gb$eog$1@dont-email.me> (permalink)
References (4 earlier) <k3pl6f$h89$3@news.albasani.net> <k3rr2o021at@news4.newsguy.com> <k3rvch$qlp$1@news.albasani.net> <k3s1dg018u@news1.newsguy.com> <k3s4f8$6ni$1@news.albasani.net>

Show all headers | View raw


On 9/25/2012 7:27 AM, The Natural Philosopher wrote:
> 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@news.albasani.net>,
>>>>>> The Natural Philosopher <tnp@invalid.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.
>
>
>

Why would you even set up a shell script to run the four programs from 
cron?  Why not just set cron up to run them itself?

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Only Allow exec in CLI cph <cloudpresshosting@gmail.com> - 2012-09-23 16:14 -0700
  Re: Only Allow exec in CLI gordonb.1zi9u@burditt.org (Gordon Burditt) - 2012-09-23 20:06 -0500
    Re: Only Allow exec in CLI cph <cloudpresshosting@gmail.com> - 2012-09-23 18:30 -0700
      Re: Only Allow exec in CLI Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-23 22:26 -0400
  Re: Only Allow exec in CLI "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-09-24 13:07 +0200
    Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-24 12:43 +0100
      Re: Only Allow exec in CLI Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-09-24 14:08 +0200
        Re: Only Allow exec in CLI Michael Vilain <vilain@NOspamcop.net> - 2012-09-24 10:45 -0700
          Re: Only Allow exec in CLI Michael Fesser <netizen@gmx.de> - 2012-09-24 23:57 +0200
      Re: Only Allow exec in CLI "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-09-24 14:16 +0200
      Re: Only Allow exec in CLI Tim Streater <timstreater@greenbee.net> - 2012-09-24 13:19 +0100
        Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-24 13:54 +0100
          Re: Only Allow exec in CLI Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-09-24 16:04 +0200
            Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-24 15:14 +0100
            Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-24 16:09 +0100
              Re: Only Allow exec in CLI Tim Streater <timstreater@greenbee.net> - 2012-09-24 19:07 +0100
          Re: Only Allow exec in CLI crankypuss <no@email.thanks> - 2012-09-25 02:47 -0600
            Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 11:00 +0100
              Re: Only Allow exec in CLI crankypuss <no@email.thanks> - 2012-09-25 04:35 -0600
                Re: Only Allow exec in CLI Tim Streater <timstreater@greenbee.net> - 2012-09-25 11:44 +0100
                Re: Only Allow exec in CLI crankypuss <no@email.thanks> - 2012-09-25 05:31 -0600
                Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 12:27 +0100
                Re: Only Allow exec in CLI Tim Streater <timstreater@greenbee.net> - 2012-09-25 12:41 +0100
                Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 12:52 +0100
                Re: Only Allow exec in CLI Tim Streater <timstreater@greenbee.net> - 2012-09-25 14:23 +0100
                Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 14:46 +0100
                Re: Only Allow exec in CLI Tim Streater <timstreater@greenbee.net> - 2012-09-25 15:55 +0100
                Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 16:13 +0100
                Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 15:05 +0100
                Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 15:05 +0100
                Re: Only Allow exec in CLI crankypuss <no@email.thanks> - 2012-09-25 12:16 -0600
                Re: Only Allow exec in CLI Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 08:10 -0400
                Re: Only Allow exec in CLI Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 07:45 -0400
                Re: Only Allow exec in CLI Anders Wegge Keller <wegge@wegge.dk> - 2012-09-25 14:57 +0200
                Re: Only Allow exec in CLI Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 09:03 -0400
                Re: Only Allow exec in CLI Anders Wegge Keller <wegge@wegge.dk> - 2012-09-25 15:37 +0200
                Re: Only Allow exec in CLI Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 12:10 -0400
                Re: Only Allow exec in CLI Anders Wegge Keller <wegge@wegge.dk> - 2012-09-25 18:25 +0200
                Re: Only Allow exec in CLI Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 14:24 -0400
                Re: Only Allow exec in CLI crankypuss <no@email.thanks> - 2012-09-25 12:38 -0600
                Re: Only Allow exec in CLI Anders Wegge Keller <wegge@wegge.dk> - 2012-09-25 20:45 +0200
                Re: Only Allow exec in CLI Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-25 16:08 -0400
                Re: Only Allow exec in CLI Michael Fesser <netizen@gmx.de> - 2012-09-25 15:12 +0200
                Re: Only Allow exec in CLI Anders Wegge Keller <wegge@wegge.dk> - 2012-09-25 15:39 +0200
                Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 14:35 +0100
      Re: Only Allow exec in CLI megazzorro <megazzorro.5jed61@no-mx.httppoint.com> - 2012-09-24 08:22 -0400
      Re: Only Allow exec in CLI crankypuss <no@email.thanks> - 2012-09-25 02:39 -0600
        Re: Only Allow exec in CLI Martin Leese <please@see.Web.for.e-mail.INVALID> - 2012-09-25 09:10 -0600
          Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 16:17 +0100
          Re: Only Allow exec in CLI crankypuss <no@email.thanks> - 2012-09-25 12:20 -0600
            Re: Only Allow exec in CLI The Natural Philosopher <tnp@invalid.invalid> - 2012-09-25 19:32 +0100
      Re: Only Allow exec in CLI Ryan <rbilesky@gmail.com> - 2012-09-27 10:23 -0700

csiph-web