Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie mactruck's Avatar
    Join Date
    Apr 2012
    City of Salt

    Launch script from website?

    So I want to make an internal website and on this website if you click a link it will launch a script on my server. Is this possible? This will be only accessible from inside my network.

  2. #2
    certainly! you mean launch a server locally on that same server running the webserver, right? then certainly.

    say your script that you want to execute is:

    you could have a CGI script that servers a webpage with a link, and if that link is clicked, then the prog is run. here's a quick example, using Perl:

    use strict;
    use warnings;
    use CGI::Carp qw(fatalsToBrowser);
    use CGI;
    # get CGI vars passed to this script via the link
    my $cgi = new CGI;
    my %qs = ();
      $qs{$_} = $cgi->param($_);
    # start HTML
    print <<"EOF";
    Content-type: text/html
    Cache-control: no-cache/no-store
    <!DOCTYPE html>
    # if link was clicked
      print "running prog via link...<p>";
      system('/tmp/ 2>&1');
    # if link hasn't been clicked yet, just show the link
      print "<a href='?link=1'>run prog</a>";
    # close HTML
    print <<"EOF";
    obviously, this is rife with insecurity. secure as needed.

    Edit: note that you need to make sure that the script is executable. otherwise, explicitly call it with the command line interpreter, e.g.:
    /bin/bash /tmp/
    Last edited by atreyu; 07-28-2013 at 01:26 AM. Reason: mark as executable

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts