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


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

php exec http url

Started bybishop2001 <lancerset@gmail.com>
First post2014-03-06 12:42 -0800
Last post2014-03-07 18:12 +0000
Articles 7 — 5 participants

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


Contents

  php exec http url bishop2001 <lancerset@gmail.com> - 2014-03-06 12:42 -0800
    Re: php exec http url Jerry Stuckle <jstucklex@attglobal.net> - 2014-03-06 16:04 -0500
    Re: php exec http url Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-07 15:09 +0100
      Re: php exec http url The Natural Philosopher <tnp@invalid.invalid> - 2014-03-07 14:55 +0000
        Re: php exec http url Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-07 16:36 +0100
          Re: php exec http url The Natural Philosopher <tnp@invalid.invalid> - 2014-03-07 20:33 +0000
    Re: php exec http url Denis McMahon <denismfmcmahon@gmail.com> - 2014-03-07 18:12 +0000

#13076 — php exec http url

Frombishop2001 <lancerset@gmail.com>
Date2014-03-06 12:42 -0800
Subjectphp exec http url
Message-ID<5573acd6-1217-446d-989d-67b2807e5075@googlegroups.com>
Greetings,
I am trying to execute a shell script which is residing on a webserver on a remote machine with no luck. I have tried the following. It looks like it runs but I never see the output from the script on machine2. Any suggestions. Thanks,

from machine 1:
echo exec('http://machine2/script.sh);

and 

from machine1:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://machine2/script.sh");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?> 

[toc] | [next] | [standalone]


#13077

FromJerry Stuckle <jstucklex@attglobal.net>
Date2014-03-06 16:04 -0500
Message-ID<lfanth$8s3$1@dont-email.me>
In reply to#13076
On 3/6/2014 3:42 PM, bishop2001 wrote:
> Greetings,
> I am trying to execute a shell script which is residing on a webserver on a remote machine with no luck. I have tried the following. It looks like it runs but I never see the output from the script on machine2. Any suggestions. Thanks,
>
> from machine 1:
> echo exec('http://machine2/script.sh);
>
> and
>
> from machine1:
> <?php
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "http://machine2/script.sh");
> curl_setopt($ch, CURLOPT_HEADER, 0);
> curl_exec($ch);
> curl_close($ch);
> ?>
>

What is the result of your curl_exec()?  How do you know the shell 
script is working?  What happens when you try to execute the shell 
script from a browser?


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

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


#13082

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-03-07 15:09 +0100
Message-ID<5743835.K3cv73TOv2@PointedEars.de>
In reply to#13076
bishop2001 wrote:
^^^^^^^^^^
Please fix.

> I am trying to execute a shell script which is residing on a webserver on
> a remote machine with no luck. I have tried the following. It looks like
> it runs but I never see the output from the script on machine2. Any
> suggestions. Thanks,
> 
> from machine 1:
> echo exec('http://machine2/script.sh);

exec() executes commands in the shell running on the local machine (where 
PHP is running), assuming it is allowed (for security reasons, it usually is 
not).  “http://machine2/script.sh” is not a command in any known shell 
script language.
 
> and
> 
> from machine1:
> <?php
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "http://machine2/script.sh");
> curl_setopt($ch, CURLOPT_HEADER, 0);
> curl_exec($ch);
> curl_close($ch);
> ?>

Even if a Web server would serve that resource, it would not execute it by 
default, IOW by default you would receive only the source code of the shell 
script, not its output.


PointedEars
-- 
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)

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


#13083

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2014-03-07 14:55 +0000
Message-ID<lfcmk6$eeq$1@news.albasani.net>
In reply to#13082
On 07/03/14 14:09, Thomas 'PointedEars' Lahn wrote:
> bishop2001 wrote:
> ^^^^^^^^^^
> Please fix.
>
>> I am trying to execute a shell script which is residing on a webserver on
>> a remote machine with no luck. I have tried the following. It looks like
>> it runs but I never see the output from the script on machine2. Any
>> suggestions. Thanks,
>>
>> from machine 1:
>> echo exec('http://machine2/script.sh);
>
> exec() executes commands in the shell running on the local machine (where
> PHP is running), assuming it is allowed (for security reasons, it usually is
> not).  “http://machine2/script.sh” is not a command in any known shell
> script language.
>
>> and
>>
>> from machine1:
>> <?php
>> $ch = curl_init();
>> curl_setopt($ch, CURLOPT_URL, "http://machine2/script.sh");
>> curl_setopt($ch, CURLOPT_HEADER, 0);
>> curl_exec($ch);
>> curl_close($ch);
>> ?>
>
> Even if a Web server would serve that resource, it would not execute it by
> default, IOW by default you would receive only the source code of the shell
> script, not its output.
>
>
> PointedEars
>

The way to do this is to set php up on the remote server to have a web 
page run that script.

e.g. on the machine2 that runs a script have a php file that does this

echo (exec('script.sh'));

and then on machine1 simply use curl to point not at the script, but at 
the URL of the php file that actually runs that script.





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


#13084

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2014-03-07 16:36 +0100
Message-ID<1433413.aqcbTOH9jL@PointedEars.de>
In reply to#13083
The Natural Philosopher wrote:
^^^^^^^^^^^^^^^^^^^^^^^
Please fix.

> On 07/03/14 14:09, Thomas 'PointedEars' Lahn wrote:
>> bishop2001 wrote:
>>> from machine1:
>>> <?php
>>> $ch = curl_init();
>>> curl_setopt($ch, CURLOPT_URL, "http://machine2/script.sh");
>>> curl_setopt($ch, CURLOPT_HEADER, 0);
>>> curl_exec($ch);
>>> curl_close($ch);
>>> ?>
>>
>> Even if a Web server would serve that resource, it would not execute it
>> by default, IOW by default you would receive only the source code of the
>> shell script, not its output.
> 
> The way to do this is to set php up on the remote server to have a web
> page run that script.
> 
> e.g. on the machine2 that runs a script have a php file that does this
> 
> echo (exec('script.sh'));
> 
> and then on machine1 simply use curl to point not at the script, but at
> the URL of the php file that actually runs that script.

That is not the only way.

Your From header field still violates RFC 5536, and several other 
conventions and rules.

Learn to quote.


PointedEars
-- 
When all you know is jQuery, every problem looks $(olvable).

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


#13086

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2014-03-07 20:33 +0000
Message-ID<lfdafh$oh8$2@news.albasani.net>
In reply to#13084
On 07/03/14 15:36, Thomas 'PointedEars' Lahn wrote:
> The Natural Philosopher wrote:
> ^^^^^^^^^^^^^^^^^^^^^^^
> Please fix.
>
>> On 07/03/14 14:09, Thomas 'PointedEars' Lahn wrote:
>>> bishop2001 wrote:
>>>> from machine1:
>>>> <?php
>>>> $ch = curl_init();
>>>> curl_setopt($ch, CURLOPT_URL, "http://machine2/script.sh");
>>>> curl_setopt($ch, CURLOPT_HEADER, 0);
>>>> curl_exec($ch);
>>>> curl_close($ch);
>>>> ?>
>>>
>>> Even if a Web server would serve that resource, it would not execute it
>>> by default, IOW by default you would receive only the source code of the
>>> shell script, not its output.
>>
>> The way to do this is to set php up on the remote server to have a web
>> page run that script.
>>
>> e.g. on the machine2 that runs a script have a php file that does this
>>
>> echo (exec('script.sh'));
>>
>> and then on machine1 simply use curl to point not at the script, but at
>> the URL of the php file that actually runs that script.
>
> That is not the only way.
>
> Your From header field still violates RFC 5536, and several other
> conventions and rules.
>
> Learn to quote.
>
>
> PointedEars
>

Fuck off noddy

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


#13085

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-03-07 18:12 +0000
Message-ID<lfd26l$s4c$1@dont-email.me>
In reply to#13076
On Thu, 06 Mar 2014 12:42:52 -0800, bishop2001 wrote:

> Greetings,
> I am trying to execute a shell script which is residing on a webserver
> on a remote machine with no luck. I have tried the following. It looks
> like it runs but I never see the output from the script on machine2. Any
> suggestions. Thanks,

Firstly, you say "It looks like it runs"

What evidence do you have for this?

> from machine 1:
> echo exec('http://machine2/script.sh);

What entries appear in the webserver logs on the server after attempting 
this? You probably want to check any log file in the apache logs dir that 
has it's timestamp modified when you try and access the script.

> from machine1:
> <?php $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "http://machine2/script.sh");
> curl_setopt($ch, CURLOPT_HEADER, 0);
> curl_exec($ch);
> curl_close($ch);
> ?>

What entries appear in the webserver logs on the server after attempting 
this?

Are you sure that the webserver is configured to run .sh files as shell 
scripts and pipe the output of the script back to the http session?

Are you sure that the script is executable by the webserver process? 
Execute permissions for relevant users / groups / world?

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [standalone]


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


csiph-web