Jump to content

php exec http shell script


bishop2001

Recommended Posts

Greetings,

I'm 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

 

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/
Share on other sites

Do you want the script to run on machine1 or machine2?

 

If you want it to run on machine1, you need to download it first to a local file then run that file with exec().

 

If you want it to run on machine2 you'd have to configure the server to run it when requested.

That is not going to happen via a http request.

 

Do you have ssh access to the remote server? Just execute it via that.

 

Otherwise, if you really want to make the request via http, you'll need to write a php script that you can request which will in turn execute your script.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.