Hi All,
I have managed a CGI script but am getting internal server error.
Can anyone pls tell me where i'm going wrong?
Pasting the code below.
----------------Code Starts--------------------------
#!/local/apps/iw-home/iw-perl/bin/iwperl -w
#-----------------------------------------------------------------------------
# File sample_cgi_task.ipl
#
# Use A sample program for use with a CGI task. This can be used
# as a starting point for a new CGI task, or as an aid in debugging
# an existing CGI task.
#
# Copyright 2003 Interwoven Inc.
# All rights reserved.
#-----------------------------------------------------------------------------
# Flush the output buffer right away.
$| = 1;
use strict; # Try to catch errors as early as possible.
# Declare which external packages and library routines will be used.
use TeamSite::CGI_lite;
use TeamSite::WFtask;
use TeamSite::WFworkflow;
# Set $DEBUG to 1 to see behind-the-scenes information that may be useful
# for debugging. Set it to 0 to hide this information.
my $DEBUG = 1;
# The task transitions (successor descriptions) that are available to this
# CGI task.
### ATTENTION: These are the two transitions from the CGI task in
### cgi_task_test.wft. If your task has different transitions,
### you will want to change this list.
my
@transitions = ("Finish Job", "Retry Later");
# Questions that we want to ask the user
### ATTENTION: These questions are used for demonstation purposes only.
### You won't want to use them for your own task.
my
@questions =
(
{ name => "name",
label => "What is your name?" },
{ name => "quest",
label => "What is your quest?" },
{ name => "color",
label => "What is your favorite color?" }
);
# Declare some constants that we will be using.
# The name of the HTTP parameter that indicates the selected task transition.
sub TRANSITION_PARAM () { "transition" }
# The name of the HTTP parameter that gives a transition comment.
sub COMMENT_PARAM () { "comment" }
# The name of the HTTP parameter that gives the task ID.
# On old versions of TeamSite, you may need to use the name
# "taskID" or "iw_taskid" instead of "task_id".
sub TASK_PARAM () { "task_id" }
# The execution of the main subroutine is wrapped inside an eval so that
# we can try to catch and report problems that arise during execution.
# This cannot not catch all problems, such as compilation errors.
eval { main(); };
if ($
@) {
write_error('An error was detected during the execution of this request:
',
TeamSite::CGI_lite->escape_html_data($
@));
}
exit;
#---------------------------------------------------------------------
# main
# Write an appropriate response to the HTTP request to
# standard output.
#
# RETURNS
# Nothing.
#---------------------------------------------------------------------
sub main
{
my $cgi = TeamSite::CGI_lite->new();
$cgi->parse_data();
# Get the value of the task ID.
my($taskId) = $cgi->{form}{&TASK_PARAM};
# If the parameter has multiple values, just use its first value.
$taskId = $$taskId[0] if (ref($taskId) eq "ARRAY");
write_header("Sample CGI Task");
my $task = TeamSite::WFtask->new($taskId);
my
@files = $task->GetFiles();
# Which transition (if any) was selected?
my $transition = $cgi->{form}{&TRANSITION_PARAM};
if (! $task->IsValid ) {
write_error("This task ($taskId) is not valid");
}
elsif ($task->GetState ne 'active') {
write_error("This task ($taskId) is not active");
}
elsif (! defined $transition) {
# This program is being run because a CGI task was just started.
# Display a form for the user's inputs.
write_error("This task ($taskId) is not active");
}
else {
# This program is being run because the user's browser sent a
# response.
# Process the inputs, activate the task callback, and display an
# acknowledgement.
}$task->CallBack(0, "No Problem with files....continue");
}
#---------------------------------------------------------------------
# write_header
# Write the beginning of an HTML response.
# ARGUMENTS
# $title - the page title of the page
# RETURNS
# Nothing.
#---------------------------------------------------------------------
sub write_header
{
my ($title) =
@_;
# NOTE: There must be a blank line between the response header and
# the start of the HTML.
print <
Content-type:text/html; charset=utf-8
< html>
< head>
< title>$title
< style>
td, th {
font-size: 12px;
}
< /style>
< /head>
< h2>$title
HEADER
}
#---------------------------------------------------------------------
# write_error
# Write a message in strong red. Used to report an
# exceptional condition.
# ARGUMENTS
# A list of values to be displayed.
# RETURNS
# Nothing.
#---------------------------------------------------------------------
sub write_error
{
print '', @_, "\n";
}
---------------------End Code-------------------------------------
I need to print out something in the window.
Later move on to read a log file and print the same. No inputs needed from the user.
Thanks,
Manikandan