www.webdeveloper.com
Results 1 to 3 of 3

Thread: CGI Header Error

  1. #1
    Join Date
    Mar 2003
    Posts
    46

    CGI Header Error

    Hello,

    In need of CGI help. I wrote a CGI script to do recursive file copy and it works when I execute the script via *nix command. When I tried to to run the script via browser it gave me a 500 error and my error log prints:

    [01/Aug/2003:14:37:53] failure (13904): for host xxx.xxx.xxx.xx trying to GET /cgi-bin/myscript.pl, cgieng_scan_headers reports: the CGI program /usr/local/htdocs/cgi-bin/myscript.pl did not produce a valid header (program terminated without a valid CGI header. Check for core dump or other abnormal termination)

    Below is my script:

    #! /usr/bin/perl
    use File::Find;
    use File::Copy;
    use File::Path;

    my $top_src = "/usr/local/htdocs/directory/copyfrom/";
    my $dest = "/usr/local/htdocs/directory/copyto/";

    find sub {
    ##might need it for later on
    ##ignore non html files
    return unless -f ;

    my $more_subdir;
    for ( $more_subdir = $File::Find::dir) {
    s#^\Q$top_src##;
    s#^/##;
    }

    ## don't copy if we already have a later file
    if (-e "$dest/$more_subdir/$_" and -M "$dest/$more_subdir/$_" <= -M
    $_) {
    ## tracing: turn off when you're happy
    ## warn "ignoring older $File::Find::name\n";
    return;
    }

    mkpath( ["$dest/$more_subdir"], 0, 0775); # $dest must be an absolute

    ## tracing: turn off when you're happy
    ##$content = warn "copying $File::Find::name to $dest/$more_subdir/$_\n";
    copy $_, "$dest/$more_subdir/$_";
    }, $top_src;

    exit;



    Thanks,

    Jenn
    Why take life so seriously when you never come out of it alive.

  2. #2
    Join Date
    Jul 2003
    Location
    The City of Roses
    Posts
    2,503
    CGI scripts always need to return an HTTP header. And this must be done before anything else is printed to STDOUT.
    Code:
    print "Content-Type: text/html\n\n";
    or
    Code:
    use CGI;
    my $cgi = CGI->new();
    print $cgi->header();
    The latter can be more useful in larger CGI applications, but rather redundant in your case. The first example should suit you fine.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  3. #3
    Join Date
    Mar 2003
    Posts
    46

    Thank you.

    I will give it a shot. Thank you Jeff.

    Jenn
    Why take life so seriously when you never come out of it alive.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles