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

I'm very new to perl and have developed 10 scripts that connect to terminal servers using net::telnet and execute commands on serial devices. I would like to automate the execution by using a web page to start, monitor and stop the scripts. Is this possible? Do I have any other options? Currently I use the perl test.pl command from the shell. I can run upto 10 perl test.pl, perl test1.pl, perl test2.pl and so on. I would like ot just have an checkbox and select the ones to execute and select go. Any thoughts? Thanks -S

Replies are listed 'Best First'.
Re: how to execute scripts using html
by tachyon (Chancellor) on Jul 13, 2004 at 04:57 UTC

    Of course it is possible. You do it using CGI. See Ovids Web Programming with Perl for an intro. You don't want to use this script but it will let you run arbitrary commands on a server through a browser using CGI. Running commands is relatively easy, making it secure is another issue entirely.

    As for other options I would just ssh in using putty.exe myself, rather than spend a lot of time wrapping a web interface on it. Tools like Webmin et al provide browser based interfaces to servers and you can hack up plugins pretty easily.

    #!/usr/bin/perl # install at your own risk! $|++; use CGI qw( :standard ); use CGI::Carp qw( fatalsToBrowser ); my $command = param('command'); print header, start_form({ -method=>'get' }), textfield({-size=>75,-na +me=>'command'}), submit('Run'), end_form; if ($command) { open( CMD, "$command 2>&1|" ) or die "$!: running command: '$command +'"; print "<pre>"; print escapeHTML($_,1) while<CMD>; print "</pre>\n", end_html; close CMD; }

    cheers

    tachyon

Re: how to execute scripts using html
by Mercio (Scribe) on Jul 13, 2004 at 08:20 UTC
    sheesh! Anythings possible in Perl... Just kidding. Well about the sheesh part anyways.

    To answer your question, wait it already was, it is very possible. You just need to use CGI to make the magic my young monk. It can be done easily through html forms and a short perl script.

    Read the tutorial that was in the above post, it will do you a lot more good if you read it then we just give you the code. However, don't be hesitant to ask us for help if you hit a few stumbling blocks.