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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I despair! no where else to turn. CGI error

Status
Not open for further replies.

m4trix

Vendor
Jul 31, 2002
84
CA
I'm trying to edit a perl forum for a friends' company, but before I can do that, I need to get it working on my local server. I'm on winXP running Apache 1.3.27, and the newest version of perl. my CGI scripts work perfectly on my server, when I write them. However, my friend sent me this script, which works fine on his server, but I can't get it to run on mine.

For example, I tried to run cp.cgi, which would configure the script for my server. But when I run it, I get:

Software error:
Can't find string terminator "END" anywhere before EOF at c:\PROGRA~1\APACHE~1\apache\cgi-bin\cp.cgi line 109.

Here is that piece of code:
[tt]
106 } elsif ($in{ubb} eq 'set_initial') {
107 &SetInitial;
108 } else {
109 print<<END;
110 Content-type: text/plain
111
112 Sorry, I can't process ubb=$in{ubb} during an initial setup. Please try again without it.
113 END
114 } # end if
115 exit(0);
116 } # end unless
[/tt]

it looks fine to me, and works in some of my other scripts.
However, if I change it so that it is:
[tt]
print &quot;Content-type: text/plain\n\n&quot;;
print &quot;Sorry, I can't process ubb=$in{ubb} during an initial setup. Please try again without it.\n&quot;;
[/tt]

it seems to work, or at least it gives me a different error. like:

Software error:
Can't find string terminator &quot;TheENV&quot; anywhere before EOF at ubb_setup.cgi line 107.

Software error:
[Sat Jan 4 01:30:07 2003] c:\PROGRA~1\APACHE~1\apache\cgi-bin\cp.cgi: Can't find string terminator &quot;TheENV&quot; anywhere before EOF at ubb_setup.cgi line 107. Compilation failed in require at c:\PROGRA~1\APACHE~1\apache\cgi-bin\cp.cgi line 101.

obviously, cp.cgi calls ubb_setup.cgi, so I open that file, and find these lines, which also look fine to me:

[tt]
104 -type => &quot;text/html&quot;,
105 );
106
107 print <<TheENV;
108 <html><head><title>UBB.classic: Your Environmental Variables</title></head>
109 <body bgcolor=&quot;#FFFFFF&quot;>
110 <font size=&quot;2&quot; face=&quot;Verdana, Arial&quot;>
111 <b>Your Environmental Variables</b>
112 <p>
113 Use this information to help you figure out your absolute file paths, and
114 other system information.
115 </p><p>
116 <b>Perl Info:</b><br />
117 You are using <b>Perl Version $]</b>
118 </p><p>
119 <b>Your Environmental Variables:</b>
120 <br />
121 <font size=&quot;1&quot;>
122 Note: &quot;DOCUMENT_ROOT&quot; shows your absolute path to your root web directory.
123 &quot;SCRIPT_FILENAME&quot; shows you absolute path of your CGI directory.
124 If your SCRIPT_FILENAME shows &quot;/125 your Absolute Path variable for your CGI directory would be
126 &quot;/ On some servers this value is
127 called PATH_TRANSLATED.</font>
128 </p>
129 </font><pre>
130 TheENV
131
132 foreach(sort {$a cmp $b} keys %ENV) {
133 printf(&quot;<b>%-25s</b>%s\n&quot;, &quot;$_:&quot;, UBBCGI::escapeHTML($ENV{$_}));
[/tt]

and so I can fix it by changing each line to it's own print statment.. but that takes a fair amount of time. becuase when I run it again, I get ANOTHER error, and ANOTHER AND ANOTHER... and it seems like an endless amount of fixing those stupid print <<FILEHANDLE; errors. I've tried changing them. usually when I code, I leave them right against the left side, and use quotation marks:

print <<&quot;FILEHANDLE&quot;;
blah blah blah
FILEHANDLE

but it still doesn't work for this script. ANY ideas? or do I just take the time one day to change it so it prints each line individually? I'd still like to know why it doesn't work though, when it works on his server
 
maybe your transfer type is not correct, you should transfer perl script by ASCII,not binary.as we know \n is not same on different os.
you can ask your friend to send it to you again and test ?
 
Forgive me if this is a dumb observation, but if those line numbers are actually in the perl code, it won't work that way. The line must contain only the print delimiter.

I know, it sounds silly, but I'm throwing it out there just in case. Tom's method should work well in any case. ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
tl66 - I'm aware of this :) but thanks for pointing it out. It's on my hd, so I don't need to ftp it anyway.

icrf - I added the line numbers myself, because I basically just took a chunk of code out and I wanted readers to have some kind of reference to where it came from.

tanderso - thanks, I'll try that
 
Make sure that the END label at line 113 of your code snipet
is flush against the left side of the script.
No spaces or anything else on that line before it.


crackn101
 
Also, make sure that there is a carriage return after END, and preferrably a blank line. There's always a better way...
 
I reckon tl66 may be on the right track. What editor are you using to edit the script? Some editors automatically change the line terminators to suit the OS, and some stick with whatever line terminators are present in the file sent to you. Try using something like:


Cheers, Neil
 
According to the perl pages, putting quotes around the first terminator will fix the problem. As in:

print <<'END';

Regards,
Pat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top