Execute script through a browser

Associate
Joined
2 Jul 2004
Posts
1,430
Hi, whats the best way to tack the issue of allowing a user to login and execute a script through an internet browser ?

Cheers.
 
toosepin said:
What kind of script are we talking about?

Hi,

A Shell script (which simply starts an exe if it is not already running).

Its fine logging in via SSH to do it, but it needs to be done through a web browser button so that a user cant run any other shell commands.

So... Web browser button executes a shell script.

Cheers.
 
Have your button redirect to a CGI script written in perl (or pretty much any language you like) that calls the script.
For example:

!/usr/bin/perl
use CGI qw(param);
print CGI::header();
@args = ("command", "arg1", "arg2");
system(@args) == 0
or die "system @args failed: $?"
print "<html><body>Command Executed!</body></html>";

The user that runs apache will need to have permissions to access yoru script (called "command" in the example). Arg1 and Arg2 are args passed to your script.

Note: I haven't tested this code let me know if it doesn't work.
 
Back
Top Bottom