bishop2001 Posted March 6, 2014 Share Posted March 6, 2014 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);?> Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/ Share on other sites More sharing options...
QuickOldCar Posted March 6, 2014 Share Posted March 6, 2014 (edited) Tried this my server to another, and my result showed the contents of the sh file Edited March 6, 2014 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/#findComment-1471686 Share on other sites More sharing options...
kicken Posted March 7, 2014 Share Posted March 7, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/#findComment-1471700 Share on other sites More sharing options...
bishop2001 Posted March 7, 2014 Author Share Posted March 7, 2014 so I want the script to reside on machine2 but to be executed from machine1. Sort of like running a remote rsh command. Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/#findComment-1471776 Share on other sites More sharing options...
bishop2001 Posted March 7, 2014 Author Share Posted March 7, 2014 regarding: Tried this on my server to another, and my result showed the contents of the sh file I get the same thing, it will show me the contents of the remote shell script but not actually execute it. Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/#findComment-1471777 Share on other sites More sharing options...
trq Posted March 7, 2014 Share Posted March 7, 2014 Of course it does. What exactly do you expect to happen? Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/#findComment-1471779 Share on other sites More sharing options...
bishop2001 Posted March 7, 2014 Author Share Posted March 7, 2014 I would like the remote shell script to execute rather than show me the contents Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/#findComment-1471783 Share on other sites More sharing options...
trq Posted March 8, 2014 Share Posted March 8, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/286772-php-exec-http-shell-script/#findComment-1471844 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.