LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-21-2009, 12:29 AM   #1
JATA01
Member
 
Registered: Nov 2007
Posts: 207

Rep: Reputation: 15
Lightbulb 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-
 
Old 01-21-2009, 12:33 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
Quote:
Please help me its urgent!!
Actually, we help in our spare time on a voluntary basis, therefore its only 'urgent' to you.
http://catb.org/~esr/faqs/smart-questions.html

I strongly suggest you add

Code:
use strict;
use warnings;
to the top of your code; it'll save you a lot of grief.
Please also use code tags for easier reading.

What is the apparent problem with your code?
 
Old 01-21-2009, 01:10 AM   #3
JATA01
Member
 
Registered: Nov 2007
Posts: 207

Original Poster
Rep: Reputation: 15
Thanks Cris,

Sorry to ask for help in such manner, but I need to complete it immediately.

And I am very fresher in this field.

Thanks-
 
Old 01-26-2009, 11:48 AM   #4
JATA01
Member
 
Registered: Nov 2007
Posts: 207

Original Poster
Rep: Reputation: 15
Can I espect any input from you friends???
 
Old 01-26-2009, 02:04 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,753

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by JATA01 View Post
Can I espect any input from you friends???
As Chrism01 explained, this isn't urgent for anyone but you. Don't say it's urgent.

You were given tips to use, and asked a simple question:

Quote:
What is the apparent problem with your code?
You don't say if you followed the tips you were given, or what the problem is. I doubt if any of us are going to put your script onto one of our servers to debug it for you, so you're actually going to have to tell us what the error(s) are.

If you don't want to take the advice you were given and answer the questions, good luck.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cgi-perl JATA01 Linux - Software 2 01-08-2009 02:27 AM
help in perl cgi john83reuben Programming 1 03-26-2008 11:23 AM
Perl CGI:Can't locate CGI.pm supermyself Programming 13 09-10-2007 06:22 AM
perl cgi neil Programming 3 07-07-2004 04:52 AM
cgi perl : I cant get perl to append my html file... the_y_man Programming 3 03-22-2004 05:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration