LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Stupid script question (https://www.linuxquestions.org/questions/linux-general-1/stupid-script-question-391811/)

internetbutterflies 12-12-2005 02:19 AM

Stupid script question
 
I've been trying to run scripts on my linux/apache server. They end up a disasterous mess.

[error] [client 70.59.56.252] (8)Exec format error: exec of '/www/cgi-bin/chat.cgi' failed
[Sun Dec 11 23:21:22 2005] [error] [client 70.59.56.252] Premature end of script headers: chat.cgi

internetbutterflies.com/cgi-bin/chat.cgi

It doesn't seem to matter what script I use, or where I put it. Either I get the internal error page, or a page full of half script language in my browser. I point the file to the perl file on the server and it basically tells me to take a flying leap. Completely stupid i'm sure, but i'll be darned if I can figure this out. Any suggestions?

bigearsbilly 12-12-2005 09:26 AM

The script would help.
I think this message means your script is not
formatting the page right. (I ain't CGI'd for a while)

Is it perl?
If so you can run the script at the command line
and even pass paremetrs (like you see in urls)

e.g:
Code:

./script var=fish  >  test.html
you can even try my skeleton cgi script if you like:

Code:

!/usr/bin/perl -w
use CGI qw( :standard );

my $comment = << "EOF";
# This template is for standalone cgi scripts that
# don't interact with shell scripts but simply run
# a command and print the output, including errors.
#
# A simple template CGI with one example form.
# (added just as an illustration)
# which can be removed, along with this comment.
#
# there is debugging code included too
# just comment it out when it's ready to release.
#
EOF

# ALL YOU NEED TO DO IS:
#
# change these to required values
# uncommenting the debug will remove the sample form and debug stuff
# the comment above will still be output though, so change it to
# something sensible!
# ===============================
my $title = "Skeleton CGI script for running a shell command";
my $command = "/usr/bin/date";
my $debug = 1;
# $debug = 0;

# don't touch these or put any output before them
# ===============================================
my $machine = $ENV{'SERVER_NAME'};

# COOKIE stuff
# ~~~~~~~~~~~~
# if param text exists, set the cookie to it
# else take the value of previous cookie (null if no previous)
# ============================================================
$cookie_name = 'skel_cookie';
$cookie_value = param('text') || cookie($cookie_name);
$cookie1 = cookie(  -name=>$cookie_name,
                    -value=>$cookie_value,
                    -expires=>'+1y' );


###

print  header( -cookie=>$cookie1 );
print start_html({ title=>"$title",
                    author=>"billy", }), h1($title);


# DEBUGGING
# =========
#
# If you are debugging CGIs you need to look at
# /var/apache/logs/error_log
#
# do a 'tail -f best idea

#use strict;

# debug, print params
# ===================
sub print_params
{
    if (param()) {
       
        print qq(<pre>);
        foreach $param (param()) {
            print "$param = " . param($param) . "\n" ;
        }
        print qq(</pre>);
    }
    if ( $string = cookie($cookie_name) ) {
        print h4("cookie => " . $string);
    }
        print hr;
}


sub dump_env
{
    print hr;
    print "<pre>";
    print "ENV\n";
    foreach $key ( keys %ENV ) {
        print p("$key $ENV{$key}");
        print "$key=[$ENV{$key}]";
    }
    print "</pre>";
    print hr;
}

sub run_command
{
    my $command = "@_";

    print p("Running $command [$machine]");
    print hr;
    print "<pre>";
    open OUT, "2>&1 @_ |";
    print p($_) while (<OUT>);
    print "</pre>";
    print hr;
}
sub sample_form {
    print start_multipart_form;
    print textfield( {-name=>'text', -value=>$cookie_value });
    print submit( {-name=>'button', -value=>'OK'});
    print end_form;
}



All times are GMT -5. The time now is 10:14 PM.