-3

I have a bash and perl script in a file located on a linux server instance running on AWS. I am attempting to put a web application on that same server that would server as a GUI to run that script. (I.E. put a button on a web page that, when clicked, would run the script located on the same server but in the bin directory)

Thank you

  • 5
    You forgot to ask a question. – mob Nov 16 '12 at 23:47
  • @mob I feel like it was self explanatory without a question. – Eduk8tedMynd Nov 17 '12 at 15:13
  • @tjameson I have tried using php and now I am working on using cgi. I have a bash script with some perl embedded that creates site directories each time it is run. Now I am trying to make gui site for a user to click a button to run that script without having to ssh into the server – Eduk8tedMynd Nov 17 '12 at 15:15

3 Answers3

3

Once you have a webserver setup in your language of choice, make a handler for your request of choice. Once that's done, Google exec <language>, where <language> is the language you're writing it in. Here are references for a few popular languages:

Community
  • 1
  • 1
beatgammit
  • 19,817
  • 19
  • 86
  • 129
2

I'm not sure how your server is setup and there's a possibility that the apache user might not have correct permissions to run some commands but like most programming languages like php have a command for running external commands.

Checkout - http://php.net/manual/en/function.exec.php

Codeguy007
  • 891
  • 1
  • 12
  • 32
2

Step 1: Install a HTTP server
Step 2: Configure the server to handle certain files in a certain directory as CGI scripts.
Step 3: Add a <form> to your page that POSTs to a CGI script. Include a submit button. This isn't really a web-appy thing, running scripts on servers is ancient. See the guestbooks and counter-images of 90s webpages.

The script itself would look something like (in Perl):

#!/usr/bin/perl
use CGI;

# the following line is *strongly* recommended
use strict; use warnings; use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new();
print $cgi->header();
exec "/usr/bin/script-I-want-to-run", "--switch", "value";

In Bash this might work:

#!/bin/sh
echo "Content-type: text/plain"
echo ""
/usr/bin/script-or-whatever --switch value

Perl's CGI module will even help you with getting $cgi->parameters and stuff and can be absolutely recommended. You will find a lot of (mostly bad) tutorials on Perl CGI scripting in the interwebs when you ask Google. Read them anyway.

amon
  • 57,091
  • 2
  • 89
  • 149