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


Groups > comp.lang.php > #7103 > unrolled thread

Only Allow exec in CLI

Started bycph <cloudpresshosting@gmail.com>
First post2012-09-23 16:14 -0700
Last post2012-09-27 10:23 -0700
Articles 20 on this page of 52 — 14 participants

Back to article view | Back to comp.lang.php


Contents

  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

Page 1 of 3  [1] 2 3  Next page →


#7103 — Only Allow exec in CLI

Fromcph <cloudpresshosting@gmail.com>
Date2012-09-23 16:14 -0700
SubjectOnly Allow exec in CLI
Message-ID<1f781456-ae7b-441a-9a07-237a5a99624d@googlegroups.com>
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. I believe I heard this is possible but I would just like to confirm this or find a workaround.

[toc] | [next] | [standalone]


#7104

Fromgordonb.1zi9u@burditt.org (Gordon Burditt)
Date2012-09-23 20:06 -0500
Message-ID<W8idndcs2oi9L8LNnZ2dnUVZ_sSdnZ2d@posted.internetamerica>
In reply to#7103
> 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. I believe I heard this is possible but I would just like to
> confirm this or find a workaround.

You can specify a directory to look for php.ini on the command line
( -c <directory> ) for the CLI version of PHP.  Thus, that cron job
can use a completely different php.ini with different configuration
than any other use of PHP.  Does that meet your requirements?
Use the --ini option to find out what files it's actually loading.

You might want to put the job in a wrapper shell script.

[toc] | [prev] | [next] | [standalone]


#7105

Fromcph <cloudpresshosting@gmail.com>
Date2012-09-23 18:30 -0700
Message-ID<a4b4e78a-a3d1-469b-83a6-825283a023e4@googlegroups.com>
In reply to#7104
On Sunday, September 23, 2012 6:06:41 PM UTC-7, Gordon Burditt wrote:
> > 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. I believe I heard this is possible but I would just like to
> 
> > confirm this or find a workaround.
> 
> 
> 
> You can specify a directory to look for php.ini on the command line
> 
> ( -c <directory> ) for the CLI version of PHP.  Thus, that cron job
> 
> can use a completely different php.ini with different configuration
> 
> than any other use of PHP.  Does that meet your requirements?
> 
> Use the --ini option to find out what files it's actually loading.
> 
> 
> 
> You might want to put the job in a wrapper shell script.

For security I assume there is no way for a php script on the server to switch to the php.ini that has exec() enabled.

That is, if a customer has ftp access to a site for them, they are forced to use the php.ini setup that disables it.

[toc] | [prev] | [next] | [standalone]


#7106

FromJerry Stuckle <jstucklex@attglobal.net>
Date2012-09-23 22:26 -0400
Message-ID<k3ogcf$jjk$1@dont-email.me>
In reply to#7105
On 9/23/2012 9:30 PM, cph wrote:
> On Sunday, September 23, 2012 6:06:41 PM UTC-7, Gordon Burditt wrote:
>>> 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. I believe I heard this is possible but I would just like to
>>
>>> confirm this or find a workaround.
>>
>>
>>
>> You can specify a directory to look for php.ini on the command line
>>
>> ( -c <directory> ) for the CLI version of PHP.  Thus, that cron job
>>
>> can use a completely different php.ini with different configuration
>>
>> than any other use of PHP.  Does that meet your requirements?
>>
>> Use the --ini option to find out what files it's actually loading.
>>
>>
>>
>> You might want to put the job in a wrapper shell script.
>
> For security I assume there is no way for a php script on the server to switch to the php.ini that has exec() enabled.
>
> That is, if a customer has ftp access to a site for them, they are forced to use the php.ini setup that disables it.
>

There is no way if your system administrator has properly set up Linux 
security.

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

[toc] | [prev] | [next] | [standalone]


#7107

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2012-09-24 13:07 +0200
Message-ID<acat7lF9jluU1@mid.uni-berlin.de>
In reply to#7103
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.

/Str.

[toc] | [prev] | [next] | [standalone]


#7108

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2012-09-24 12:43 +0100
Message-ID<k3ph16$7ur$5@news.albasani.net>
In reply to#7107
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.
> 
> /Str.

I cant imagine why anyone would put PHP in a cron job to start with.

Shell script or C, or both...

-- 
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.

[toc] | [prev] | [next] | [standalone]


#7109

FromErwin Moller <erwinmollerusenet@xs4all.nl>
Date2012-09-24 14:08 +0200
Message-ID<50604d45$0$6941$e4fe514c@news2.news.xs4all.nl>
In reply to#7108
On 9/24/2012 1:43 PM, The Natural Philosopher 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.
>>
>> /Str.
>
> I cant imagine why anyone would put PHP in a cron job to start with.
>
> Shell script or C, or both...
>

Hi TNP,

When I have written a lot of functionality in PHP, and only need to run 
some small part of it, then a cronjob is the fastest way to implement that.

I have a bunch of scripts that run both as webpage or cronjob, depending 
on a single param in the querystring.
eg:

sendDailyEmails.php?cronjob=Y

If the cronjob=Y is there, the script won't produce any output.
If it isn't there, It will be very verbose. The output I used to inspect 
and debug.
The same script can be called from the admin-pages, and as a cronjob.

So, sometimes it is easy to make PHP run as a cronjob.

To stay remotely relevant to this thread, let me add this:
On my install I had 2 different php.ini's: one for apache for normal 
webrequests, one for the cronjob.

Regards,
Erwin Moller


-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

[toc] | [prev] | [next] | [standalone]


#7117

FromMichael Vilain <vilain@NOspamcop.net>
Date2012-09-24 10:45 -0700
Message-ID<vilain-8AEBB8.10450024092012@news.individual.net>
In reply to#7109
In article <50604d45$0$6941$e4fe514c@news2.news.xs4all.nl>,
 Erwin Moller <erwinmollerusenet@xs4all.nl> wrote:

> On 9/24/2012 1:43 PM, The Natural Philosopher 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.
> >>
> >> /Str.
> >
> > I cant imagine why anyone would put PHP in a cron job to start with.
> >
> > Shell script or C, or both...
> >
> 
> Hi TNP,
> 
> When I have written a lot of functionality in PHP, and only need to run 
> some small part of it, then a cronjob is the fastest way to implement that.
> 
> I have a bunch of scripts that run both as webpage or cronjob, depending 
> on a single param in the querystring.
> eg:
> 
> sendDailyEmails.php?cronjob=Y
> 
> If the cronjob=Y is there, the script won't produce any output.
> If it isn't there, It will be very verbose. The output I used to inspect 
> and debug.
> The same script can be called from the admin-pages, and as a cronjob.
> 
> So, sometimes it is easy to make PHP run as a cronjob.
> 
> To stay remotely relevant to this thread, let me add this:
> On my install I had 2 different php.ini's: one for apache for normal 
> webrequests, one for the cronjob.
> 
> Regards,
> Erwin Moller

Actually, Drupal has a specific script that runs as a cron to check for 
updates.  And when stuff runs as a cron, the parameter passing uses the 
CLI p1 p2 p3 arguments rather than the web-style "?cronjob=Y".  There 
must be an environment variable you can query in php that will tell you 
it's being run as a CLI or CGI script.

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]

[toc] | [prev] | [next] | [standalone]


#7119

FromMichael Fesser <netizen@gmx.de>
Date2012-09-24 23:57 +0200
Message-ID<vnl168tuqa2f1sk56dnhooh4lfd13ql25m@mfesser.de>
In reply to#7117
.oO(Michael Vilain)

>Actually, Drupal has a specific script that runs as a cron to check for 
>updates.  And when stuff runs as a cron, the parameter passing uses the 
>CLI p1 p2 p3 arguments rather than the web-style "?cronjob=Y".  There 
>must be an environment variable you can query in php that will tell you 
>it's being run as a CLI or CGI script.

You can also use wget to call the script via HTTP.

Micha

-- 
http://mfesser.de/
Fotos | Blog | Flohmarkt

[toc] | [prev] | [next] | [standalone]


#7110

From"M. Strobel" <sorry_no_mail_here@nowhere.dee>
Date2012-09-24 14:16 +0200
Message-ID<acb18kFahquU1@mid.uni-berlin.de>
In reply to#7108
Am 24.09.2012 13:43, schrieb The Natural Philosopher:

> I cant imagine why anyone would put PHP in a cron job to start with.
> 
> Shell script or C, or both...
> 

If you have a proper separation of application logic and presentation, you can use
your functions/classes for periodic check of consistency of your data.

Or for an offline import, or report, ...

/Str.

[toc] | [prev] | [next] | [standalone]


#7111

FromTim Streater <timstreater@greenbee.net>
Date2012-09-24 13:19 +0100
Message-ID<timstreater-360AD6.13190924092012@news.individual.net>
In reply to#7108
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.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#7112

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2012-09-24 13:54 +0100
Message-ID<k3pl6f$h89$3@news.albasani.net>
In reply to#7111
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.


-- 
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.

[toc] | [prev] | [next] | [standalone]


#7114

FromErwin Moller <erwinmollerusenet@xs4all.nl>
Date2012-09-24 16:04 +0200
Message-ID<5060685f$0$6962$e4fe514c@news2.news.xs4all.nl>
In reply to#7112
On 9/24/2012 2:54 PM, 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.
>

Of course there are many things you can do in C and not in PHP.
Like writing drivers for your graphics card.

But realistically, what multitasking cronjobs do you exactly envision 
here? I cannot think of one.

Regards,
Erwin Moller


-- 
"That which can be asserted without evidence, can be dismissed without 
evidence."
-- Christopher Hitchens

[toc] | [prev] | [next] | [standalone]


#7115

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2012-09-24 15:14 +0100
Message-ID<k3pprq$shr$1@news.albasani.net>
In reply to#7114
Erwin Moller wrote:
> On 9/24/2012 2:54 PM, 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.
>>
> 
> Of course there are many things you can do in C and not in PHP.
> Like writing drivers for your graphics card.
> 
> But realistically, what multitasking cronjobs do you exactly envision 
> here? I cannot think of one.
> 

Multitasking *for one thing*. Not the only difference. ONE difference.

There are dozens more libraries doing custom stuff better than PHP .

Else why would the OP NEED to 'exec'?









> Regards,
> Erwin Moller
> 
> 


-- 
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.

[toc] | [prev] | [next] | [standalone]


#7116

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2012-09-24 16:09 +0100
Message-ID<k3pt3a$44d$1@news.albasani.net>
In reply to#7114
Erwin Moller wrote:
> On 9/24/2012 2:54 PM, 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.
>>
> 
> Of course there are many things you can do in C and not in PHP.
> Like writing drivers for your graphics card.
> 
> But realistically, what multitasking cronjobs do you exactly envision 
> here? I cannot think of one.
> 

Multitasking *for one thing*. Not the only difference. ONE difference.

There are dozens more libraries doing custom stuff better than PHP .

Else why would the OP NEED to 'exec'?

SNMP support is gruesome in PHP, though its not a lot better in 'C',
admittedly. :-)






> Regards,
> Erwin Moller
> 
> 


-- 
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.

[toc] | [prev] | [next] | [standalone]


#7118

FromTim Streater <timstreater@greenbee.net>
Date2012-09-24 19:07 +0100
Message-ID<timstreater-4CE50C.19073524092012@news.individual.net>
In reply to#7116
In article <k3pt3a$44d$1@news.albasani.net>,
 The Natural Philosopher <tnp@invalid.invalid> wrote:

> Erwin Moller wrote:
> > On 9/24/2012 2:54 PM, The Natural Philosopher wrote:
> >> Tim Streater wrote:
> >>> In article <k3ph16$7ur$5@news.albasani.net>,
> >>> The Natural Philosopher <tnp@invalid.invalid> wrote:

> >>>> 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.
> >>
> > 
> > Of course there are many things you can do in C and not in PHP.
> > Like writing drivers for your graphics card.
> > 
> > But realistically, what multitasking cronjobs do you exactly envision 
> > here? I cannot think of one.

> Multitasking *for one thing*. Not the only difference. ONE difference.
> 
> There are dozens more libraries doing custom stuff better than PHP .
> 
> Else why would the OP NEED to 'exec'?

Prolly to do specific things that you can't do in PHP. Hmmm, furtle, 
furtle:

Looks like I do it:

1) to open a file using the designated app for the file, in a window on 
the user's screen. So I do:

  $cmd = "/usr/bin/open \"" . $filename . "\" 2>&1";
  exec ($cmd, $results, $result);

or possibly:

  exec ("/usr/bin/open -a Safari.app 'http://...");


2) Starting and stopping apache, as in:

  $cmd = "/usr/sbin/httpd -f \"" . $fno . "\" 2>&1";
  exec ($cmd, $results, $result);

or the same with -k stop.

But I agree, these are not in cron jobs. Although if I had a cron job to 
run I'd prolly do it in PHP if at all possible.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#7121

Fromcrankypuss <no@email.thanks>
Date2012-09-25 02:47 -0600
Message-ID<k3rr2o021at@news4.newsguy.com>
In reply to#7112
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

[toc] | [prev] | [next] | [standalone]


#7122

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2012-09-25 11:00 +0100
Message-ID<k3rvch$qlp$1@news.albasani.net>
In reply to#7121
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.


-- 
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.

[toc] | [prev] | [next] | [standalone]


#7123

Fromcrankypuss <no@email.thanks>
Date2012-09-25 04:35 -0600
Message-ID<k3s1dg018u@news1.newsguy.com>
In reply to#7122
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.

[toc] | [prev] | [next] | [standalone]


#7124

FromTim Streater <timstreater@greenbee.net>
Date2012-09-25 11:44 +0100
Message-ID<timstreater-AB2D00.11444725092012@news.individual.net>
In reply to#7123
In article <k3s1dg018u@news1.newsguy.com>, crankypuss <no@email.thanks> 
wrote:

> 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.

Yes, not having to use shell script utter shite to do some work is worth 
any possible bit of extra inefficiency (always assuming there is some), 
given that it saves lots of *my* time.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | comp.lang.php


csiph-web