Hi, all. I use FC5 linux to develop CGI program. The config file of Apache are defaule and I put my script on /var/www/cgi-bin/ folder. I do not modify any config file in FC5 and shutdown the firewall. But I find I can not use the IO::socket module in the apache web environment. The script is below:
#!/usr/bin/perl use strict; use warnings; use IO::Socket; my $pop3 = IO::Socket::INET->new( PeerAddr => "pop3.163.com", PeerPort => 110, Proto => 'tcp', Timeout => 20 ); print "Content-type: text/html\n\n"; print "Result: "; print $pop3;
The permission of the script file is 755, and the path of the file is /var/www/cgi-bin/test_socket.pl

When I run the script in command line. It print the result:

Content-type: text/html Result: IO::Socket::INET=GLOB(0x9314838)
But I run it in apache by the URL: http://192.168.0.200/cgi-bin/test_socket.pl . It only print:

Content-type: text/html Result:
It seem that the value of the $pop3 is undef. So the use of IO::Socket is failed on apache.

Why have this problem. How can I get the rignt result?

DuanXuepeng.


In reply to IO::Socket error in CGI on apache by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.