CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [KevinR] Perl cgi calling shell script: Edit Log

Veteran / Moderator

Aug 6, 2009, 11:05 AM

Views: 20492
Re: [KevinR] Perl cgi calling shell script

Personally, I'd use radio buttons instead of the multiple submit buttons and I'd use a dispatch table.

Here's the modified version with those changes.


use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $q = CGI->new;
my %form = $q->Vars;

print $q->header(),
$q->start_html(-title=>'Select branch'),
$q->h3({-style=>'Color: red;'},'Select branch from the Drop Down List below...');

my @vlist = `/home/e027449/bin/lockctrl -s -show -br | awk '{print \$1}'`;

### start form your code ####
print $q->start_form();
print $q->popup_menu(-name => 'list',
-id => 'list',
-values => \@vlist,
-default => 'stp_rel_08_02_copy_only');

print $q->radio_group(-name => 'action',
-values => ['Lock','UnLock','Status','ManualCron'],
-default => 'Lock');

print $q->p,

print $q->end_form();

### end your form code ######

print $q->br, "Selected value: ", $q->param('list') if $q->param('list');

my %action = (
Lock => sub {
print $q->p("executing lock\n");
my $status = `/home/e027449/bin/lockctrl -s -lock -br $form{'list'} -repository stp`;

if (! $status ){
print $q->h2 ("$form{'list'} Branch is now locked");
else {
print "Lock not executing\n";

UnLock => sub {
print $q->p("executing unlock\n");
my $script = "/usr/local/adm/branch_key $form{'list'} 'unlock'";
my $status = system($script);
if (! $status ){
print $q->h2 ("$form{'list'} Branch is now unlocked");

Status => sub {
print $q->p("executing status\n");
my $script = "/home/e027449/bin/lockctrl -s -show -br $form{'list'}";
my $status = system($script);

ManualCron => sub {
my $script = "/usr/local/adm/email.cronbuild405 '$form{'list'} Manual CronBuild' > /tmp/buildlog405.$form{'list'}.$$ 2>&1";
my $status = system($script);
if (! $status ){
print $q->h2 ("Manual Cron for $form{'list'} Branch is done please check your email for results");

if ( exists $form{'action'} ) {
$action{ $form{'action'} }->();

print $q->hidden(mode=>'save');
print $q->end_html();

(This post was edited by FishMonger on Aug 6, 2009, 11:08 AM)

Edit Log:
Post edited by FishMonger (Veteran) on Aug 6, 2009, 11:08 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives