Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm getting a strange error message. Help! 4

Status
Not open for further replies.

garymgordon

Programmer
Apr 5, 2000
307
US
If you would kindly take a look at this url.

Then hit the submit button (without even entering any data).

You'll get an error.

My problem is ... I don't understand what might be causing the error. WHAT SHOULD I CHECK OR DO?



I hope someone can help.

Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
you form line sez this:[tt]
action="/cgi-bin/web_tech_support/index.cgi/new"
[/tt]
do you mean to have the last '/new' on there? "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Yes.

It is also on this site ... and working fine.

I can't figure out for the life of me .. why this error is happening.


I set this up today as well.

But on this other site, it is giving me the error.

Please ... HELP! I am lost on this.

Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
The error I am getting is...

Software error:
(Maybe you didn't strip carriage returns after a network transfer?)


What would cause this ... any ideas??

Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
Could this line ...

use CGI::Carp qw(fatalsToBrowser carpout);


be a problem??

Would it be possible that the server I am on doesn't have this loaded??

Would this cause the error .. AND ... what can I run to quickly test if Carp is loaded on the server??


Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
well then, the best guess i have is that it's in the configuration of the webserver... put a dummy cgi that does nothing but print out the values for %ENV or something in the same directory with the same permissions and see if you can get it to work. if you can't, then it's definitely something with the config of webserver/cgi handler... if it does work... well, i'll think of that in the mean time. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Can you (if you would) write me something fast that I can load up and try - as you suggested. I don't know how to write what you described. Thanks!

By the way, I found Carp.pm loaded. So it is there.

Thanks,
Gary

PS: I'll give you the results of the script after I run it. (So, I'll look for it shortly - if you would be so kind.)

Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
[tt]#!/usr/local/bin/perl -w

print "Content-type: text/html\n\n";
foreach (keys %ENV)
{
print "$_ : ", $ENV{$_}, "\n";
}
[/tt]

"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
My output from the script is:


SERVER_SOFTWARE : Apache/1.3.19 (Unix) PHP/4.0.4pl1 FrontPage/4.0.4.3 GATEWAY_INTERFACE : CGI/1.1 DOCUMENT_ROOT : / REMOTE_ADDR : 24.180.190.47 SERVER_PROTOCOL : HTTP/1.1 REQUEST_METHOD : GET QUERY_STRING : HTTP_USER_AGENT : Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) PATH : /usr/local/bin:/usr/bin:/bin HTTP_ACCEPT : */* HTTP_CONNECTION : Keep-Alive REMOTE_PORT : 4149 HTTP_ACCEPT_LANGUAGE : en-us SCRIPT_NAME : /cgi-bin/web_tech_support/test_for_env.cgi HTTP_ACCEPT_ENCODING : gzip, deflate SCRIPT_FILENAME : / SERVER_NAME : HTTP_COOKIE : board1=988590894 SERVER_PORT : 80 HTTP_EXTENSION : Security/Remote-Passphrase HTTP_HOST : SERVER_ADMIN : webmaster@garymgordon.com


NOW WHAT? :)

Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
that means that the problem is probly in the script somewhere. i haven't found the problem yet, but in your code, in the sub 'check_ticket', you have this:[tt]
while(<DATA>) {
@all = split(/\n/);
foreach $line (@all) {
#code[/tt]

when you say 'while(<FILE>)', the loop sets $_ to each line of the file, so splitting it on '\n' will return a single entry. instead of the while loop, do this:[tt]
@all = <DATA>;
foreach $line (@all) {[/tt]


that's just something i noticed. i haven't found the source of it dying like it is... &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Well,...

I did what you suggested and now I am getting this error.

Software error:
Execution of index.cgi aborted due to compilation errors.

I made the modification as:

@all = <DATA>;
foreach $line (@all) {

# while(<DATA>) {
# @all = split(/\n/);
# foreach $line (@all) {

(Just commented out the other three lines. ... and then also noticed that I needed to take out one additional &quot; } &quot; since there were 2 in the three lines we commented out.) Then, ... when I got rid of an extra &quot; } &quot; ... I got this error again.


Software error:
(Maybe you didn't strip carriage returns after a network transfer?)


Any new thoughts???

PS: I really appreciate your assistance with this.

:)
Gary


Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
er... well, here: post that particular subroutine as it stands, as well as the values for any variables it uses from the files you load in. let the world have a go at this, as well as give me another perspective. (*sigh* if only CGI::carp gave a better error message in this case...)
also, you may also want to post the equivelent code from the script that works, for comparison sake. in fact, if you have the working copy lying around, send it to me <stillflame@go.com> and i can post the relevent differences myself, and work from there.

... &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
There is a FAQ in the CGI forum that walks through several simple examples, faq452-653. The CGI forum seems to be drying up and blowing away as we are getting a lot of CGI postings here. Are we intentionally posting CGI stuff to the Perl forum? Are we muddying the Perl waters?????

'just asking...


I hope the faq is useful.


keep the rudder amid ship and beware the odd typo
 
Stillflame,

Here's the index.cgi script that the new.html page is being forwarded to (in the action).

This is the same as the one that is working. The only difference is .. this one ... on a different server ... isn't. hahaha

The one that is working is on VERIO. The one that isn't working is on CIHOST.




#!/usr/bin/perl

require '/home/garymgordon/require '/home/garymgordon/
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser carpout);

############### MAIN PROGRAM ###############################
############################################################

my $script_url = url();
my $form = path_info();
$form =~ s!^/!!;

if (!$form) {
show_request_form();
}

elsif ($form eq 'new') {
my $name = param('name');
my $username = param('username');
my $domain = param('domain');
my $email = param('email');
my $problem = param('problem');
my $priority = param('priority');

check_url();

# Clean problem field
$problem =~ s/\cM//g;
$problem =~ s/\n/ /g;

check_fields($name,$username,$domain,$email,$problem);

my $date = get_date(); # Get date
my $ticket = assign_ticket(); # Get ticket number

write_database($ticket,$date,$name,$username,$domain,$email,$problem,$priority);
email_ticket($ticket,$name,$email);

if ($notify) {
email_me($ticket,$name,$username,$domain,$email,$problem,$priority);
}

print_details($ticket,$name,$username,$domain,$email,$problem,$priority);

}

elsif ($form eq 'view') {
show_status_form()
}

elsif ($form eq 'show') {
my $ticket = param('ticket');
my $username = param('username');

check_ticket($ticket,$username);
}

else {
error_page(&quot;<li>Illegal calling of script.&quot;);
}

############### FUNCTIONS AND SUBROUTINES ##################
############################################################

sub show_request_form {
my $nr;

open (NEW_REQUEST, &quot;$new_request_tpl&quot;) || error_page(&quot;<li>Can't find template file&quot;);
&lock_file(*NEW_REQUEST);
while (<NEW_REQUEST>) {
$nr .= $_;
}
close (NEW_REQUEST);

$nr =~ s/\[SCRIPT_URL\]/$script_url/egs;
$nr =~ s/\[VERSION NUMBER\]/$version_no/egs;

print &quot;Content-type: text/html\n\n&quot;;
print &quot;$nr&quot;;
exit(0);
}

sub check_fields {
my ($errmsg,$message,$errmsg);
my $name = shift;
my $username = shift;
my $domain = shift;
my $email = shift;
my $problem = shift;

$errmsg = &quot;<li>Your name seems to be missing.\n&quot;;
if ($name eq &quot;&quot;) {
$message = $message.$errmsg;
$found_err = 1;
}
$errmsg = &quot;<li>Please enter a valid email address.\n&quot;;
if ($email !~ /^[\w\-\.\!\%\+\/]+\@[a-zA-z0-9\-]+(\.[a-zA-Z0-9\-]+)*\.[a-zA-Z0-9\-]+$/) {
$message = $message.$errmsg;
$found_err = 1;
}
$errmsg = &quot;<li>Your username seems to be missing.\n&quot;;
if ($username eq &quot;&quot;) {
$message = $message.$errmsg;
$found_err = 1;
}
$errmsg = &quot;<li>Your domain name seems to be missing.\n&quot;;
if ($domain eq &quot;&quot;) {
$message = $message.$errmsg;
$found_err = 1;
}
$errmsg = &quot;<li>Where's your problem?\n&quot;;
if ($problem eq &quot;&quot;) {
$message = $message.$errmsg;
$found_err = 1;
}
if ($found_err) {
error_page($message);
}
}

sub get_date {
@days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
@months = ('January','February','March','April','May','June','July','August','September','October','November','December');
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf(&quot;%02d:%02d:%02d&quot;,$hour,$min,$sec);
$year += 1900;

my $date = &quot;$days[$wday], $months[$mon] $mday at $time&quot;;
return $date;
}

sub assign_ticket {
my $ticket;

if (-e &quot;$countdb&quot;) {
open (NUMBER,&quot;$countdb&quot;) || error_page(&quot;<li>Can't open $countdb&quot;);
&lock_file(*NUMBER);
$ticket = <NUMBER>;
close(NUMBER);

open (NUM,&quot;>$countdb&quot;) || error_page(&quot;<li>Can't write to $countdb&quot;);
&lock_file(*NUM);
$ticket++;
print NUM &quot;$ticket&quot;;
close(NUM);
} else {
error_page(&quot;<li>Count file missing. Please inform the site administrator&quot;);
}

return $ticket;
}

sub write_database {
my $ticket = shift;
my $date = shift;
my $name = shift;
my $username = shift;
my $domain = shift;
my $email = shift;
my $problem = shift;
my $priority = shift;

if (-e &quot;$maindb&quot;) {
open (DFILE, &quot;>>$maindb&quot;) || error_page(&quot;<li>Can't append to $maindb&quot;);
&lock_file(*DFILE);
print DFILE &quot;$ticket|$date|$name|$username|$domain|$email|$problem|$priority||0\n&quot;;
close(DFILE);
} else {
error_page(&quot;<li>Main database is missing. Please inform the site administrator&quot;);
}
}

sub email_ticket {
my $tp;
my $ticket = shift;
my $name = shift;
my $email = shift;

if (-e &quot;$email_tpl&quot;) {
open(TEMPLATE, &quot;$email_tpl&quot;) || &error_page(&quot;<li>Can't open email message template.&quot;);
&lock_file(*TEMPLATE);
while (<TEMPLATE>) {
$tp .= $_;
}
close(TEMPLATE);

$tp =~ s/\[TICKET\]/$ticket/egs;
$tp =~ s/\[NAME\]/$name/egs;
$tp =~ s/\[EMAIL\]/$email/egs;
$tp =~ s/\[SCRIPT_URL\]/$script_url/egs;

open(MAIL, &quot;|$mailprog -t&quot;) || error_page(&quot;<li>Can't find sendmail program&quot;);
print MAIL &quot;$tp&quot;;
close(MAIL);
} else {
error_page(&quot;<li>Can't find the email message template&quot;);
}
}

sub email_me {
my $ticket = shift;
my $name = shift;
my $username = shift;
my $domain = shift;
my $email = shift;
my $problem = shift;
my $priority = shift;

open (MAIL,&quot;|$mailprog -t&quot;) || error_page(&quot;<li>Can't find sendmail program&quot;);
print MAIL <<&quot;HERE&quot;;
To: $notifywho
From: $name <$email>
Subject: New Support Request ID $ticket

There is a new request for support.
The following information was submitted:

Ticket number: $ticket
Name: $name
Email: $email
Username: $username
Domain: $domain
Problem: $problem
Priority: $priority

HERE
close (MAIL);
}

sub print_details {
my $template;
my $ticket = shift;
my $name = shift;
my $username = shift;
my $domain = shift;
my $email = shift;
my $problem = shift;
my $priority = shift;

open (TEMPLATE, &quot;$request_details_tpl&quot;) || error_page(&quot;<li>Can't open template file&quot;);
&lock_file(*TEMPLATE);
while (<TEMPLATE>) {
$template .= $_;
}
close (TEMPLATE);

$template =~ s/\[VERSION NUMBER\]/$version_no/egs;
$template =~ s/\[SCRIPT_URL\]/$script_url/egs;

$template =~ s/\[TICKET\]/$ticket/egs;
$template =~ s/\[NAME\]/$name/egs;
$template =~ s/\[USERNAME\]/$username/egs;
$template =~ s/\[DOMAIN\]/$domain/egs;
$template =~ s/\[EMAIL\]/$email/egs;
$template =~ s/\[PROBLEM\]/$problem/egs;
$template =~ s/\[PRIORITY\]/$priority/egs;

print &quot;Content-type: text/html\n\n&quot;;
print &quot;$template&quot;;
exit(0);
}

sub show_status_form {
my $ss;

open (STATUS, &quot;$view_status_tpl&quot;) || error_page(&quot;<li>Can't find template file&quot;);
&lock_file(*STATUS);
while (<STATUS>) {
$ss .= $_;
}
close (STATUS);

$ss =~ s/\[VERSION NUMBER\]/$version_no/egs;
$ss =~ s/\[SCRIPT_URL\]/$script_url/egs;

print &quot;Content-type: text/html\n\n&quot;;
print &quot;$ss&quot;;
exit(0);
}

sub check_ticket {
my (@all,$found,$line,$template,$ticket,$date,$name,$username,$domain,$email,$problem,$priority,$solution,$status);
my $t = shift;
my $u = shift;

$found = 0; # Initialize boolean variable

if (-e &quot;$maindb&quot;) {
open (DATA, &quot;$maindb&quot;) || error_page(&quot;<li>Can't open $maindb&quot;);
&lock_file(*DATA);
while(<DATA>) {
@all = split(/\n/);
foreach $line (@all) {
($ticket,$date,$name,$username,$domain,$email,$problem,$priority,$solution,$status) = split(/\|/, $line);
if ($ticket eq &quot;$t&quot; && $username eq &quot;$u&quot;) {
$found = 1;

# Make status readable
if ($status eq &quot;0&quot;) { $status = &quot;New&quot; }
if ($status eq &quot;1&quot;) { $status = &quot;Assigned&quot; }
if ($status eq &quot;2&quot;) { $status = &quot;Completed&quot; }

# Show ticket details
open (TEMPLATE, &quot;$ticket_view_tpl&quot;) || error_page(&quot;<li>Can't open template file&quot;);
&lock_file(*TEMPLATE);
while (<TEMPLATE>) {
$template .= $_;
}
close (TEMPLATE);

$template =~ s/\[VERSION NUMBER\]/$version_no/egs;

$template =~ s/\[DATE\]/$date/egs;
$template =~ s/\[STATUS\]/$status/egs;
$template =~ s/\[TICKET\]/$ticket/egs;
$template =~ s/\[NAME\]/$name/egs;
$template =~ s/\[USERNAME\]/$username/egs;
$template =~ s/\[DOMAIN\]/$domain/egs;
$template =~ s/\[EMAIL\]/$email/egs;
$template =~ s/\[PROBLEM\]/$problem/egs;
$template =~ s/\[SOLUTION\]/$solution/egs;
$template =~ s/\[PRIORITY\]/$priority/egs;

print &quot;Content-type: text/html\n\n&quot;;
print &quot;$template&quot;;
exit(0);
}
}
}
} else {
error_page(&quot;<li>Main database cannot be found&quot;);
}
close(DATA);

if (!$found) {
error_page(&quot;<li>Wrong combination of ticket number and username&quot;)
}
}




Thanks,
Gary


ANYONE ... PLEASE!!

I saw the cgi not from goBoating, but didn't see anything that indicated why I'm getting the error I am getting.

HELP!!!!



Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
well, i stripped down your script to one that didn't call any external methods or require any of the files you opened, and it worked.
until someone else thinks of something, here's what i suggest:
you need to figure out where the problem is, and the first thing that comes to my mind is also the lamest debugging method to my knowledge: make calls to &error_page systematically throughout your code till you find out exactly where the error is (put them further and further into execution until it doesn't come up). include in the call to error_page some distinguishing information (line number works). if i were better with the perl debugger, i'd suggest that. it'd be a nice time to learn how to use it now, if you wanted to try.

(note: if you ever work on a moderately huge project, please don't rely on this debugging method. it's waaaay to slow. by then, you'll probly have more experience anyway, and know better techniques.)

HTH &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Stillflame,

THANKS!

Last night I figured out the problem.

I emailed the programmer, who created the script .. and they emailed me back (thank goodness) and simply told me that THE ERROR message I was getting was specific to fact that I had uploaded a ASCII file in BINARY format.

Anyhow .. when I was uploading the file using CUTE FTP, certain files that had weird extensions such as .tpl and .conf were not in my list of ASCII extensions. So, it was considering these as BINARY.

That was why the error message was reading as it did.

It wasn't a problem with the script. (But I am not saying that the script is perfect, but the script was not causing the error I was getting.)

I sincerely thank you for your help!!!

But, it now works fine.

Thanks again for all your help and the time that you put into looking at the script. I am actually glad you looked at it and basically verified that not much is wrong.

So, thanks!

:)
Gary
Gary M. Gordon, LLC
webmaster@garymgordon.com
Certified Web Developer ::
Application Programmer
 
NP. i learned a new bug to look out for myself.
(not painlessly, but then, what good learning is :) ) &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Here's a little trick I use. If you're uploading ascii files from a windows system to a *nix system you can check to see if they were uploaded in binary format or not by searching the first line of the file for /\x0d\x0a/. If the file was uploaded in binary that string will match, otherwise it will not (it will have been converted to just \x0d).
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top