spickles has asked for the wisdom of the Perl Monks concerning the following question:

Monks -

Since my perl script uses STDIN/STDOUT and is run from the command-line with Active State performing the compilation, is there a way to 'port' such a script to the web so that I could run it as a CGI script on my Apache web server? My goal is to make my script available to the public, and I would not expect people to have to download and install a Perl compiler to run it. So is it possible to use a web interface to act as a terminal and accept/display user input/output?

Regards,
Scott
  • Comment on Port a script with STDIN/STDOUT to CGI?

Replies are listed 'Best First'.
Re: Port a script with STDIN/STDOUT to CGI?
by ww (Archbishop) on Aug 31, 2009 at 00:35 UTC
Re: Port a script with STDIN/STDOUT to CGI?
by NetWallah (Canon) on Aug 31, 2009 at 05:14 UTC
    You are probably looking for something like WebConsole.

    From their website:

    Web Console is a web-based application that allows remote users to execute UNIX/Windows shell commands on a server, upload/download files to/from server, edit text files directly on a server and much more. The application is represented as a web page that accepts user input such as a command, executes that command on a remote web server, and shows command output in a browser. As well, simple and functional file manager build-in into the application. Web Console is open-source software written on Perl using AJAX technology. ...
    This would be quick and dirty. For a more user-friendly solution, you would probably have to redesign your program interface to be web-browser/form oriented, and use CGI as others have suggested.

         Potentia vobiscum ! (Si hoc legere scis nimium eruditionis habes)

Re: Port a script with STDIN/STDOUT to CGI?
by Anonymous Monk on Aug 31, 2009 at 00:30 UTC
    Simply rewrite your script not to use STDIN/STDOUT for argument passing, and use CGI to process parameters
Re: Port a script with STDIN/STDOUT to CGI?
by ikegami (Patriarch) on Aug 31, 2009 at 19:47 UTC
    #!/usr/bin/perl use CGI; my $cgi = CGI->new(); if ($cgi->request_method() eq 'POST') { if (my ($my_param) = $cgi->param('my_param')) { print($cgi->header('text/plain')); close(STDERR); open(STDERR, '>&', \*STDOUT); exec 'my_prog', $my_param; } } print($cgi->header('text/html')); print(<<'__EOI__'); <title>my_prog</title> <form method="POST"> <h1>my_prog</h1> <p>my_param: <input type="text" name="my_param"> </form> __EOI__ }
      Monks -

      That's what I figured. I'm familiar with CGI, it's just going to be a major PITA to have to re-write with all of those post-backs.

      Thanks.