This is a discussion on PHP web interface for shell script or command within the PHP Language forums, part of the PHP Programming Forums category; I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am looking for a web interface for shell commands or shell scripts.
Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then passes these as arguments to a configurable shell script or OS command. I would like for the output generated from the shell script/command shall be displayed in a new javascript window once the form is submitted. Optimally a user should not not be able to make the program run more than once from within the javascript window by reloading the window. program execution shall only be caused by submitting the original form. -Inet |
|
|||
|
On Jun 12, 4:15 pm, Michael Vilain <vil...@NOspamcop.net> wrote:
> In article > <c1620cd5-0506-440a-b259-f0e815e64...@a70g2000hsh.googlegroups.com>, > > inetquestion<inetquest...@hotmail.com> wrote: > > I am looking for a web interface for shell commands or shell scripts. > > Does anyone know of any exexisting php scripts which would solve this > > requirement? > > > PHP form accepts input from a user, then passes these as arguments to > > a configurable shell script or OS command. I would like for the > > output generated from the shell script/command shall be displayed in a > > new javascript window once the form is submitted. Optimally a user > > should not not be able to make the program run more than once from > > within the javascript window by reloading the window. program > > execution shall only be caused by submitting the original form. > > > -Inet > > Sounds like a homework assignment or something assigned in a beginner's > PHP class. Why not try to write you own version and when you get stuck, > post your problems to this group. You might learn something. Just a > thought. > > Alternately, you can look at some of stuff in various php libraries. > Lots of php developers from various countries have posted code to > various PHP sites (hint: it starts with "g" and ends with "e"). Lots of the requirements were simplified down to make the request seem simplistic and consumable to a broader base. I assure you I'm long past homework problems. :) The root problem I'm trying to work around is I have a shell script that SSH's out to many servers using ssh key-pairs and performs various commands on each one (based on the input options/arguments) This needs to run as a specific user and needs for the environment from which it runs to be setup properly. when I setup a php based form to execute these commands, the shell it runs under is...limited at best. I have even tried sourcing the user's .profile as part of this routine, but that didn't' get me much farther. Is there a way to control what user the script will actually run as? Now back to my original questions... Are there any php utilities anyone knows of which can serve as an interface to a shell script or command line? -Inet |
|
|||
|
inetquestion wrote:
> On Jun 12, 4:15 pm, Michael Vilain <vil...@NOspamcop.net> wrote: >> In article >> <c1620cd5-0506-440a-b259-f0e815e64...@a70g2000hsh.googlegroups.com>, >> >> inetquestion<inetquest...@hotmail.com> wrote: >>> I am looking for a web interface for shell commands or shell scripts. >>> Does anyone know of any exexisting php scripts which would solve this >>> requirement? >>> PHP form accepts input from a user, then passes these as arguments to >>> a configurable shell script or OS command. I would like for the >>> output generated from the shell script/command shall be displayed in a >>> new javascript window once the form is submitted. Optimally a user >>> should not not be able to make the program run more than once from >>> within the javascript window by reloading the window. program >>> execution shall only be caused by submitting the original form. >>> -Inet >> Sounds like a homework assignment or something assigned in a beginner's >> PHP class. Why not try to write you own version and when you get stuck, >> post your problems to this group. You might learn something. Just a >> thought. >> >> Alternately, you can look at some of stuff in various php libraries. >> Lots of php developers from various countries have posted code to >> various PHP sites (hint: it starts with "g" and ends with "e"). > > > > > > Lots of the requirements were simplified down to make the request seem > simplistic and consumable to a broader base. I assure you I'm long > past homework problems. :) > > The root problem I'm trying to work around is I have a shell script > that SSH's out to many servers using ssh key-pairs and performs > various commands on each one (based on the input options/arguments) > This needs to run as a specific user and needs for the environment > from which it runs to be setup properly. when I setup a php based > form to execute these commands, the shell it runs under is...limited > at best. I have even tried sourcing the user's .profile as part of > this routine, but that didn't' get me much farther. Is there a way to > control what user the script will actually run as? Now back to my > original questions... Are there any php utilities anyone knows of > which can serve as an interface to a shell script or command line? > > -Inet > No utilities I know of - just the standard system(), exec(), etc. commands. The command will run as the PHP user - this is how the OS works, and PHP has no control over it. If you're running under Linux, you can use sudo to change the user. Also, you *could* use posix_setuid() to change the user id, but this requires special privileges on the PHP executable and is *very dangerous*. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
I have considered the following conditions, but ran into problems with
each... 1. The Web server runs as 'nobody' which cannot be modified. php scripts executed will be executed as nobody...and script doesn't work. For what I'm trying to do setuid probably isn't a good fit due to security concerns. 2. web interface could write form inputs to a file. A daemon would read items off the file and execute the intended script running as the proper user. (seems clunky to me, but would work...) 3. Any other suggestions? -Inet |
|
|||
|
On Jun 12, 10:21 pm, inetquestion <inetquest...@hotmail.com> wrote:
> I have considered the following conditions, but ran into problems with > each... > > 1. The Web server runs as 'nobody' which cannot be modified. php > scripts executed will be executed as nobody...and script doesn't > work. For what I'm trying to do setuid probably isn't a good fit due > to security concerns. > > 2. web interface could write form inputs to a file. A daemon would > read items off the file and execute the intended script running as the > proper user. (seems clunky to me, but would work...) > > 3. Any other suggestions? > > -Inet I wish I would have saved my code!! prior to my current job as a web developer I use to work Help Desk. I was using php from the command line to 'code myself out of a job' . I don't remember much from it but what I can recall you won't have much with system_exec("ssh -u root blah blah vlah") because you won't be able to interact with it after that. You need to play around with sockets, google for php telnet sockets or something to that nature . I may have the bookmarks somewhere. I think I may have printed out what code I did have and filed it under CS at my desk. I think they way I was going to do it was have a listing service that the front end connect to. The service keeps the connection alive/open new ones. I'll see what I have/remember when I get back to work Monday, I think you get the gist of the idea. I wish I had more for you as I was going down this route before. |
|
|||
|
On Jun 13, 4:36 pm, The Hajj <hajji.hims...@gmail.com> wrote:
> On Jun 12, 10:21 pm,inetquestion<inetquest...@hotmail.com> wrote: > > > I have considered the following conditions, but ran into problems with > > each... > > > 1. The Web server runs as 'nobody' which cannot be modified. php > > scripts executed will be executed as nobody...and script doesn't > > work. For what I'm trying to do setuid probably isn't a good fit due > > to security concerns. > > > 2. web interface could write form inputs to a file. A daemon would > > read items off the file and execute the intended script running as the > > proper user. (seems clunky to me, but would work...) > > > 3. Any other suggestions? > > > -Inet > > I wish I would have saved my code!! prior to my current job as a web > developer I use to work Help Desk. I was using php from the command > line to 'code myself out of a job' . I don't remember much from it but > what I can recall you won't have much with system_exec("ssh -u root > blah blah vlah") because you won't be able to interact with it after > that. > > You need to play around with sockets, google for php telnet sockets or > something to that nature . I may have the bookmarks somewhere. I think > I may have printed out what code I did have and filed it under CS at > my desk. I think they way I was going to do it was have a listing > service that the front end connect to. The service keeps the > connection alive/open new ones. I'll see what I have/remember when I > get back to work Monday, I think you get the gist of the idea. I wish > I had more for you as I was going down this route before. Any examples you have would be great. In the meantime I will checkout your suggestion. |