[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-WebCGI] SMS Perl CGI



Jona asked:

>Until now, I have not been able to make the CGI run.
>
>If I call the CGI, nothing happens, the script times out, or
>gives a "socket not connected" error to the browser.

?? Which is it ??

>The CGI stays open on the server,

Which means it ran.

>and does not quit.

Normal behavior for a MacPerl CGI is to stay open for 5 minutes.

>I have to do a hard reboot of the G4 to be able to stop
>the CGI.

Did you try selecting the CGI from the applications menu and clicking 
the "Quit Now" button?

>This happens if I save it as a CGI and a ACGI.

This is not relevant to your current problem, but...

DO NOT USE ACGI!  Always name your file .cgi

>Also llocating more memory to the CGI does not help.

Probably irrelevant at this point.

When I tried to run your script, I had to change the URL of the CGI 
to that of my server, but then got (bogus) output.

Having gone through the above, I see two potential problems right away:

1) The lines:

$EOL = "\015\012";
print "Content-type: text/html\n\n";

The "correct" newline for the web is the $EOL you have defined.  In 
MacPerl, "\n" outputs just "\015".  On my server, this works anyway, 
but you might as well do it correctly:

print "Content-type: text/html$EOL$EOL";

(I think this doesn't matter in the rest of the script in that 
newlines are irrelevant in HTML anyway, but I prepare myself for 
correction on this point.)


2) The script contains the line:
	$num=`cat /usr/web/SMS/num`;

    This will not work on a Mac for two reasons.

    i-  In general, calls to other programs which use e.g. `backtics` are not
        supported.
    ii- The syntax used for paths on the Mac/in MacPerl is different than that
        for Unix.

    A possible related problem is that I don't see the file "num" 
anywhere in your stuffed folder.  Let's say the hard drive on your 
Mac is called "Spare", and that your CGI directory is named "cgi-bin" 
in folder "html" on "Spare".  To make this work on a Mac you need to 
open and read the file using all Perl:

open(INPFILE, "Spare:html:cgi-bin:num") || die "Can't open file num: $!\n";
$num = <INPFILE>;

    Also, the line:

open(SAVE,">/usr/web/SMS/num");

... has the wrong syntax for Mac paths.

Finally, when I dealt with all that, I found that the call to:

		$remote = IO::Socket::INET->new( Proto     => "tcp",
                                          PeerAddr  => $aircallIP,
                                          PeerPort  => $aircallPort,
		);

...never returned (e.g. hung).  I assume that means that TCP server 
never responded.  I think that connect should have a timeout 
associated with it, but I'm not an IO::Socket guru, maybe someone 
else can comment on that.  (If that is in fact where you are stuck, 
then I can't help except to say that rather than reboot the server, 
you can select MacPerl from the Applications menu, do a 
<cmnd><opt><escape> to force quit, then do the same thing to the CGI.)

HTH,

-David-

p.s. I think running this on a *nix server would be much easier than 
trying to get it to work on a Mac, but I'm not sure that will be 
easier to run it on a PC, if by a PC you mean a Windows computer.
David Steffen, Ph.D.
President, Biomedical Computing, Inc. <http://www.biomedcomp.com/>
Phone: (713) 610-9770 FAX: (713) 610-9769 E-mail: steffen@biomedcomp.com

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org