Member
Registered: Nov 2007
Posts: 207
Rep:
|
Cgi-perl
Hello Friends,
I am new to cgi-perl and want help from experienced person.
My scenarion is to write a perl-cgi script, which will call a script on any system, using this script and also the output should be displayed on the page.
I am putting the script I have written, kindly help to complete this task.
#!/usr/bin/perl
use CGI;
# File: time1.pl
use CGI ':standard';
$current_time = localtime;
#
print header,
start_html('A Virtual Clock'),
h1('A Virtual Clock'),
"The current time is $current_time.",
hr,
end_html;
$base_address = '/www/';
$base_url = 'http://www.gfmdatabase.interglobetechnologies.com/~jshankar/search';
$co = new CGI;
if ($co->param()) {
$BuildExecute = $co->param('BuildExecute');
}
print $co->header,
$co->start_html
(
-title=>'CGI Example',
-author=>'Shankar',
-meta=>{'keywords'=>'CGI Perl'},
-BGCOLOR=>'pink',
-LINK=>'green'
),
$co->center
(
$co->h1
(
'Welcome CGI-BIN Script!'
)
),
$co->center
(
$co->h2
(
'IGT Script'
)
),
"Please enter your password: ",
$co->p,
$co->password_field
(
-name=>'password',
-default=>'open sesame',
-size=>30,
),
"you might be interested in ",
$co->a({href=>"http://www.cpan.org/"},"CPAN"), ".",
$co->hr,
$co->start_form
(
-name=>'form1',
-method=>'POST',
-action=>"http://abc/"
),
"Please check the script you want to execute: ",
$co->p,
$co->center
(
$co->checkbox_group
(
-name=>'checkboxes',
-values=>['Products','Build File','Go']
)
),
$co->p,
$co->hidden
(
-name=>'BuildExecute',
-override => 1,
-default => $BuildExecute
),
$co->p,
$co->center
(
$co->submit('Add to Build Execute'),
$co->reset,
),
$co->p,
$co->hr,
$co->end_form,
$co->start_form
(
-name=>'form2',
-method=>'POST',
-action=>"http://xyz/navbar/"
),
$co->hidden
(
-name=>'BuildExecute',
-override => 1,
-default => $BuildExecute
),
$co->center
(
$co->submit('Go to Build Script Location'),
),
$co->end_form,
$co->start_form
(
-name=>'form3',
-method=>'POST',
-action=>"http://www.iciciprulife.com/public/default.htm"
),
$co->hidden
(
-name=>'BuildExecute',
-override => 1,
-default => $BuildExecute
),
$co->center
(
$co->submit('See Your Build Status'),
),
$co->p,
"Please select the numbers: ",
$co->p,
$co->popup_menu
(
-name=>'popupmenu',
-value=>['Blank','1','2','3','4'],
'Blank',
),
$co->p,
"Please select the Alphabets: ",
$co->p,
$co->popup_menu
(
-name=>'popupmenu',
-value=>['Blank','A','B','C','D'],
'Blank',
),
$co->p,
"Please select the command: ",
$co->p,
$co->popup_menu
(
-name=>'popupmenu',
-value=>['Blank','ls','mkdir','cat','cd'],
'Blank',
),
$co->p,
"Please select the dir path: ",
$co->p,
$co->popup_menu
(
-name=>'popupmenu',
-value=>['Blank','/home/test','/home/test/newdir'],
'Blank',
),
$co->p,
(
$co->submit('Submit'),
$co->reset,
),
$co->p,
"Please enter your opinion: ",
$co->p,
$co->textarea
(
-name=>'textarea',
-default=>'No opinion',
-rows=>10,
-columns=>60
),
$co->p,
"Thank you for submitting Build. Please indicate how
much unsolicited mail you like to get: ",
$co->p,
$co->popup_menu
(
-name=>'popupmenu',
-values=>['Very much','A lot','Not so much','None'],
),
$co->p,
$co->hidden
(
-name=>'hiddendata',
-default=>'Rosebud'
),
$co->p,
(
$co->submit('Submit'),
$co->reset,
),
$co->start_html("Check if someone is logged in"),
$co->center
(
$co->h1("Check if someone is logged in...")
),
$co->p,
$co->start_form,
$co->center
(
"Please enter the person's login name: ",
$co->textfield('person'),
$co->p,
$co->submit('Check'),
$co->reset
),
$co->end_form;
if ($person = $co->param('person')) {
foreach (`who`) {
if (/^$person\s/) {
print
$co->center
(
$co->h2
(
"Yes, $person is logged in.",
)
),
$co->end_html;
exit;
}
}
print
$co->center
(
$co->h2
(
"$person is not logged in, sorry.",
)
);
}
$co->end_form,
$co->end_html;
___________________________________
<INPUT TYPE="hidden" NAME="selection" VALUE="$selection">
$cp->selection
my $selection = param('selection');
if ($selection ne "") {
take them to step 2
}
if ($selection =~ /1/) {
$pop2 = "A";
$pop3 = "ls";
}
if ($selection =~ /2/) {
$pop2 = "B";
$pop3 = "cd";
}
__________________________
Please help me its urgent!!
Thanks-
|