I moved this to a different server in which I have root access. However, there are still several problems. I am now using LWP. here is my code

#!/usr/local/bin/perl -w use strict; use CGI qw(:standard); use lib qw(/usr/lib/perl5/vendor_perl/5.8.6/LWP); use LWP::UserAgent; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->agent('Mozilla/5.0'); print header(), start_html(); if( param() ){ my $page_num = param("page_num"); open(fd_s, "./random_sample") or &dienice("can't open input file f +or read: $ !"); my $line = 0; my $page = 0; my $current_page = ""; while(<fd_s>){ $line++; if( $line == $page_num){ last; } } close(fd_s); $current_page = $_; print "<h3>To see what the page $line currently looks like: <a hr +ef=$curren t_page>$_</a> </h3>\n"; $line++; chomp; print "<form action=\"random_200_sites.cgi\" method=\"POST\">\n"; print "<input type=\"hidden\" name=\"url\" value=\"$_\">"; print "<input type=\"hidden\" name=\"page_num\" value=\"$line\">"; print "<h3><input type=\"radio\" name=\"decision\" value=\"spam\" +onclick=\" this.form.submit()\">spam</h3>"; print "<h3><input type=\"radio\" name=\"decision\" value=\"nonSpam +\" onclick =\"this.form.submit()\">nonSpam</h3>"; print "<h3><input type=\"radio\" name=\"decision\" value=\"very ha +rd decide\ " onclick=\"this.form.submit()\">hard to decide</h3>"; print "</form>\n"; open(OUT, ">>web.result") or &dienice("Countn't open result output + file: $! "); my $decision = param("decision"); my $url = param("url"); if($decision eq "spam"){ print OUT "$url 1\n"; }elsif($decision eq "nonSpam"){ print OUT "$url 0\n"; }else{ print OUT "$url 2\n"; } close(OUT); print hr(); my $response = $ua->get($current_page); my $data = $response->content if($response->is_success); if($data){ print "page: $current_page\n$data\ndone", length($data); } }else{ print start_form(); print p("Starts from page ",textfield("page_num")); print p(submit("go")); print end_html; } sub dienice { my($errmsg) = @_; print "<h2>Error</h2>\n"; print "<p>$errmsg</p>\n"; print end_html; exit; }
there are a few errors which have me mystified. First, all the operations related to the file handle out cause a permission problem. the file in question has everyone with read and write access, so is there any clue what the issue is?

second, as the program currently stands, there is an issue (a 500 internal server error). perl -p reveals nothing, I am clueless. I've never debugged a CGI before, so can someone give me some hint on how to fix this, and how to address these kinds of problems in general?

thanks, downer

In reply to Re^2: WGET equivalent by downer
in thread WGET equivalent by downer

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.