Click here to get back home

PHP web interface for shell script or command

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
PHP web interface for shell script or command inetquestion 06-12-2008
Get Chitika Premium
Posted by inetquestion on June 12, 2008, 1:06 pm
Please log in for more thread options
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



Posted by Michael Vilain on June 12, 2008, 4:15 pm
Please log in for more thread options
In article

> 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").

Computers are absolutly useless. All they can do is give you answers--
Pablo Picasso

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically by ignored]



Posted by inetquestion on June 12, 2008, 4:47 pm
Please log in for more thread options
> In article
>
> > 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

Posted by Jerry Stuckle on June 12, 2008, 5:12 pm
Please log in for more thread options
inetquestion wrote:
>> In article
>>
>>> 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
==================


Posted by Michael Vilain on June 12, 2008, 7:43 pm
Please log in for more thread options
In article

> > In article
> >
> > > 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

You can't control the UID of the process that's created by mod_php.
That will always be the web server's UID. This is a security feature.

The only way I've found around this restriction is a CGI tool called
CGIwrap:

http://cgiwrap.sourceforge.net/

When installed on a web server, it allows users to run a process under
any valid UNIX username. If you're using Windows, my apologies.

My ISP uses this as their secure way to run CGI scripts. If your web
host doesn't offer php as a command-line utility, all this is moot as
CGIwrap runs scripts in the context of a user's default shell.

The security for your krufty design is left as an exercise to the OP.

Good luck.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically by ignored]



Similar ThreadsPosted
How can I run shell command without getting return? March 8, 2006, 9:51 pm
a PHP script works fine when called from the browser but not as a shell script December 21, 2005, 9:06 am
shell script - to not change working directory to that of the script September 8, 2004, 1:54 pm
shell script + php July 25, 2008, 1:49 am
How can I run php scripts from a shell script? June 18, 2005, 2:27 pm
Reading Shell Script Results July 5, 2005, 7:07 am
sending a variable to a shell script? April 10, 2006, 11:04 am
how do arrays pipe from one PHP shell script to another? February 7, 2008, 10:24 pm
setting $_SERVER variables from a shell script July 19, 2007, 5:12 pm
Getting script pathname in a script run from the command line March 29, 2005, 3:11 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap