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

Mmmm....autoflush

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Can someone please explain to me why I am getting this error;

Software error:
Can't call method "autoflush" on an undefined value at submit new.cgi line 68.

when using the following code;


Code:
$host = "[URL unfurl="true"]http://www.google.com/";[/URL]
$get = "addurl?type=submit&q=$url&dq=";

        $remote = IO::Socket::INET->new( Proto     => "tcp",
                                         PeerAddr  => "$host",
                                         PeerPort  => "http(80)",
                                        );
        unless ($remote) { }
        $remote->autoflush(1);
        print $remote "GET $get HTTP/1.0" . $BLANK;

With the following 'use' options at the top of the script;

Code:
use IO::Socket;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use LWP::Simple;
use HTTP::Request;

Andy
 
Just a guess, but try putting a backslash in front of the &'s in the $get= line. Perl may be trying to interpret those as subroutine calls, which may be messing up something farther down. Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Aha. I got it :) It was the http:// bit in the $host variable. I've removed that bit now and it works fine :)

Thanks anyway

Andy
 
Mmmm. Now when ever I put a dud URL into it (to fake a dead search engine, for reporting it to the user) I get an "Can't call method "autoflush" on an undefined value at submit new.cgi line 94.".

The code is;

Code:
sub testengine
{

my $EOL = "\015\012";
my $BLANK = $EOL x 2;

my $host = "[URL unfurl="true"]www.googfgle.com";[/URL]
my $document = "/addurl?type=submit&q=$url&dq=";

        $remote = IO::Socket::INET->new( Proto     => "tcp",
                                         PeerAddr  => $host,
                                         PeerPort  => "http(80)",
                                        );
        unless ($remote) { &error_submit("Google"); }
        $remote->autoflush(1);
        print $remote "GET $document HTTP/1.0" . $BLANK;
$good_engine .= qq~ <li>Google</li> ~;

}
 
Just had a look at the error log and it says;

[Sat Jul 21 07:00:40 2001] submitnew.cgi: Can't call method &quot;autoflush&quot; on an undefined value at /home/ace-webm/public_html/cgi-bin/submitnew.cgi line 94.
Prototype mismatch: sub main::head vs ($) at /home/ace-webm/public_html/cgi-bin/submitnew.cgi line 19
Prototype mismatch: sub main::head vs ($) at /home/ace-webm/public_html/cgi-bin/submitnew.cgi line 19


Any ideas?

Thanks

Andy
 
Andy,

It's because your call to:

$remote = IO::Socket::INET->new ....

is failing, so $remote is not the object you expect it to be. Try something like this to trap a bad IP address or hostname:

$remote = IO::Socket::INET->new(....) || die &quot;bad IP address..\n&quot;;
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Mmm. I tried what you suggested. I now am using;

Code:
my $EOL = &quot;\015\012&quot;;
my $BLANK = $EOL x 2;

my $host = &quot;[URL unfurl="true"]www.googfgle.com&quot;;[/URL]
my $document = &quot;/addurl?type=submit&q=$url&dq=&quot;;

        $remote = IO::Socket::INET->new( Proto     => &quot;tcp&quot;,
                                         PeerAddr  => $host,
                                         PeerPort  => &quot;http(80)&quot;,
                                        ) || &error_submit(&quot;Google2&quot;);
        unless ($remote) { &error_submit(&quot;Google&quot;); }
        $remote->autoflush(1);
        print $remote &quot;GET $document HTTP/1.0&quot; . $BLANK;
$good_engine .= qq~ <li>Google</li> ~;

but, I now get an error saying;

Can't call method &quot;autoflush&quot; without a package or object reference at /home/ace-webm/public_html/cgi-bin/submitnew.cgi line 94.


Any help? Thanks for the help s far :) I really do love this site cos of all the great people there are out there that help dubm people like me...lol

Andy
 
Anyone got any ideas? I realy need to get this done. If no-one knows how to do this, then I wonder if anyone knows of another way to call a page and put it into a variable? Maybe LWP?

Thanks

Andy
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top