perl program works on command line, but not when run through www server 
Author Message
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\"> or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\"> or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\">
or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Hi folks.  I have been banging my head against the wall trying
to figure out what I'm doing wrong.  I am trying to write a
perl program that will schedule appointments for me.  The
The first part of the program reads in data from a file in which
appointment data is stored.  The format of the file is:

time:name

for example:

900:x
945:Chris
1030:M. Jones

and so on.  The program reads the file, and if it sees an
x, then it will print the time, the word "available" and a
radio button.  If it doesn't see an x, then it prints the
time and the name.

The problem is this:  when I run the program using
perl -w showappt.cgi,  I get a warning saying
use of uninitialized variable.  This warning is given when
the if statements are executed.  However, the program
saves the printout to the file, and when I look at the file,
everything comes out the way that I wanted.

However, when I try and run the program using lynx or netscape,
the program doesn't save anything that was printed from the
print statements.  It will print everything else.  

Originally, I had things set up so that the program would print
out straight to the browser.  I saved things to a file and then
opened a file (html formatted), and then read the file, hoping
to find the error.  No luck.

The part of the program in question is shown below:

#Now lets open the datafile for that date and establish the
#name-value pairs for the data


close(DATES);

$date = "March 3, 1997";
#$schedule_file_html = "mar0397.html";
#With the data read in from the appointment schedule for that
#date, we now display the schedule.  If the time slot is open
# a radio button is created.  If the time slot is not open,
# the name of the person who reserved that time slot is
#shown.
open (SCHEDULE,">mar0397.html");

print SCHEDULE "<html>\n";
print SCHEDULE "<head>\n";
print SCHEDULE "<title>\n";
print SCHEDULE "Schedule\n";
print SCHEDULE "</title>\n";
print SCHEDULE "</head>\n";
print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
print SCHEDULE "<h1><center>Schedule for $date\n";
print SCHEDULE "<p>\n";
print SCHEDULE "</center></h1><br>\n";
print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
03\">\n";
print SCHEDULE "<p>\n";

open (DATES,"<mar0397.dat");
while (<DATES>) {
chop;
($time,$student) = split(/:/,$_,2);
print "help help help";
if ($time eq "900") {
$proper_time = "9:00 am";

Quote:
}

elsif ($time eq "945") {
$proper_time = "9:45 am";
Quote:
}

elsif ($time eq "1030") {
$proper_time = "10:30 am";
Quote:
}

elsif ($time eq "1115") {
$proper_time = "11:15 am";
Quote:
}

elsif ($time eq "1300") {
$proper_time = "1:00 pm";
Quote:
}

elsif ($time eq "1345") {
$proper_time = "1:45 pm";
Quote:
}

elsif ($time eq "1430") {
$proper_time = "2:30 pm";
Quote:
}

elsif ($time eq "1515") {
$proper_time = "3:15 pm";
Quote:
}

elsif ($time eq "1600") {
$proper_time = "4:00 pm";
Quote:
}
else {
}

if ($student eq "x") {
print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
= \"time\" value =\"$time\"><br>\n";
Quote:
}

else {
print SCHEDULE "$proper_time \t $student<br>\n";
Quote:
}
}

print SCHEDULE "<center>\n";
print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\"> or
<input type = \"reset\" value = \"Redo your selection\"><br>\n";
print SCHEDULE "</center><br>\n";
print SCHEDULE "</form>\n";
print SCHEDULE "</body></html>\n";
close SCHEDULE;

print "Content-type: text/html\n\n";
open(SCHEDULE_FILE, "<mar0397.html");
while(<SCHEDULE_FILE>) {
print;

Quote:
}

close SCHEDULE_FILE;

Quote:
}

So, to summarize:

perl -w showappt.cgi will show use of uninitialized variables
in the if statements.

When executed from the command line, mar0397.html file will have
the proper html code.

When executed using lynx or netscape, the file will not show
any print statements executed from the if statements.

I have checked the if statements, and they are executing

the information is being read in properly.

Any help would be greatly appreciated!

Chris Engel



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Chris> However, when I try and run the program using lynx or netscape,
Chris> the program doesn't save anything that was printed from the
Chris> print statements.  It will print everything else.

This tells us that you are having a rather common _cgi_ problem, not a
Perl probelm, since your code works, from the command line.  There is
a whole other newsgroup devoted to dealing with these problems called
comp.infosystems.www.authoring.cgi.  Try posting there for these sorts
of problems.  They have an excellent FAQ that will help you solve your
cgi problem in a flash.  There is also an idiots guide to solvin cgi
problems at:

http://www.perl.com/perl/faq/perl-cgi-faq.html

This should set you right.

-jeff



Mon, 23 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server

Many apologies to those out there who saw this message posted 6 times (a
bit much).  The use of Netscape's newsgroup thing and a twitchy mousepad
will be discontinued in favour of ye good auld keyboard.  Also, thank you
to those who did respond (without flaming for duplicate posting). A few
CS students who looked at it were also puzzled why the thing didn't work
(we still can't figure that one out)

Many thanks!

Chris

Quote:

> Date: Thu, 06 MAR 1997 04:56:41 -0400

> Newgroups: comp.lang.perl.misc
> Subject: perl program works on command line, but not when run through www server

> Hi folks.  I have been banging my head against the wall trying
> to figure out what I'm doing wrong.  I am trying to write a
> perl program that will schedule appointments for me.  The
> The first part of the program reads in data from a file in which
> appointment data is stored.  The format of the file is:

> time:name

> for example:

> 900:x
> 945:Chris
> 1030:M. Jones

> and so on.  The program reads the file, and if it sees an
> x, then it will print the time, the word "available" and a
> radio button.  If it doesn't see an x, then it prints the
> time and the name.

> The problem is this:  when I run the program using
> perl -w showappt.cgi,  I get a warning saying
> use of uninitialized variable.  This warning is given when
> the if statements are executed.  However, the program
> saves the printout to the file, and when I look at the file,
> everything comes out the way that I wanted.

> However, when I try and run the program using lynx or netscape,
> the program doesn't save anything that was printed from the
> print statements.  It will print everything else.  

> Originally, I had things set up so that the program would print
> out straight to the browser.  I saved things to a file and then
> opened a file (html formatted), and then read the file, hoping
> to find the error.  No luck.

> The part of the program in question is shown below:

> #Now lets open the datafile for that date and establish the
> #name-value pairs for the data

> open (DATES, "<mar0397.dat");

> close(DATES);

> $date = "March 3, 1997";
> #$schedule_file_html = "mar0397.html";
> #With the data read in from the appointment schedule for that
> #date, we now display the schedule.  If the time slot is open
> # a radio button is created.  If the time slot is not open,
> # the name of the person who reserved that time slot is
> #shown.
> open (SCHEDULE,">mar0397.html");

> print SCHEDULE "<html>\n";
> print SCHEDULE "<head>\n";
> print SCHEDULE "<title>\n";
> print SCHEDULE "Schedule\n";
> print SCHEDULE "</title>\n";
> print SCHEDULE "</head>\n";
> print SCHEDULE "<body bgcolor=\"#ffffff\">\n";
> print SCHEDULE "<h1><center>Schedule for $date\n";
> print SCHEDULE "<p>\n";
> print SCHEDULE "</center></h1><br>\n";
> print SCHEDULE "<form method = \"POST\" action = \"readenv.cgi\">\n";
> print SCHEDULE "<input type = \"hidden\" name = \"date\" value = \"March
> 03\">\n";
> print SCHEDULE "<p>\n";

> open (DATES,"<mar0397.dat");
> while (<DATES>) {
> chop;
> ($time,$student) = split(/:/,$_,2);
> print "help help help";
> if ($time eq "900") {
> $proper_time = "9:00 am";
> }
> elsif ($time eq "945") {
> $proper_time = "9:45 am";
> }
> elsif ($time eq "1030") {
> $proper_time = "10:30 am";
> }
> elsif ($time eq "1115") {
> $proper_time = "11:15 am";
> }
> elsif ($time eq "1300") {
> $proper_time = "1:00 pm";
> }
> elsif ($time eq "1345") {
> $proper_time = "1:45 pm";
> }
> elsif ($time eq "1430") {
> $proper_time = "2:30 pm";
> }
> elsif ($time eq "1515") {
> $proper_time = "3:15 pm";
> }
> elsif ($time eq "1600") {
> $proper_time = "4:00 pm";
> }
> else {
> }
> if ($student eq "x") {
> print SCHEDULE "$proper_time \t available \t <input type = \"radio\" name
> = \"time\" value =\"$time\"><br>\n";
> }
> else {
> print SCHEDULE "$proper_time \t $student<br>\n";
> }
> }
> print SCHEDULE "<center>\n";
> print SCHEDULE "<input type = \"submit\" value = \"Reserve your time\"> or
> <input type = \"reset\" value = \"Redo your selection\"><br>\n";
> print SCHEDULE "</center><br>\n";
> print SCHEDULE "</form>\n";
> print SCHEDULE "</body></html>\n";
> close SCHEDULE;

> print "Content-type: text/html\n\n";
> open(SCHEDULE_FILE, "<mar0397.html");
> while(<SCHEDULE_FILE>) {
> print;
> }
> close SCHEDULE_FILE;
> }

> So, to summarize:

> perl -w showappt.cgi will show use of uninitialized variables
> in the if statements.

> When executed from the command line, mar0397.html file will have
> the proper html code.

> When executed using lynx or netscape, the file will not show
> any print statements executed from the if statements.

> I have checked the if statements, and they are executing

> the information is being read in properly.

> Any help would be greatly appreciated!

> Chris Engel



Tue, 24 Aug 1999 03:00:00 GMT  
 perl program works on command line, but not when run through www server


+ Any help would be greatly appreciated!

See my sig...

James

--
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>



Tue, 24 Aug 1999 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. -F works on command line but not on #!perl -paF line

2. Run perl script on web server from command line

3. Perl daemon (demon) runs from command line but not in startup script

4. Script error:"did not produce a valid header", but runs ok from command line

5. GD.pm problem: script runs fine on command line but not across webserver

6. Running a command line program from script

7. Send mail script not working in 2nd server but working in 1st server

8. Send mail script not working in 2nd server but working in 1st server

9. command line args not working correctly

10. system call works in command line mode but not from web

11. System call works at command line but not within CGI

12. Blat works from command line but not in CGI script

 

 
Powered by phpBB® Forum Software