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

Home » Imported messages » comp.lang.php » php exec http url
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: php exec http url [message #185189 is a reply to message #185188] Fri, 07 March 2014 14:55 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Experienced Web designer required
Next Topic: When a random file is not found then what?
Goto Forum:
  

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

Current Time: Thu Nov 21 21:55:32 GMT 2024

Total time taken to generate the page: 0.03203 seconds