Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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