LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-12-2005, 02:19 AM   #1
internetbutterflies
LQ Newbie
 
Registered: Dec 2005
Location: Colorado, US
Posts: 1

Rep: Reputation: 0
Wink 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?
 
Old 12-12-2005, 09:26 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
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;
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Stupid, stupid question; I lost Klaptop. :( Surfrider Slackware 2 08-31-2005 09:12 PM
Stupid Dumb Stupid Question... drigz Linux - Software 3 09-23-2004 03:09 PM
bash script - even more stupid question than last time. webamoeba Linux - Newbie 2 02-12-2004 03:03 AM
Maybe a stupid question.... Coolstar Linux - Software 1 11-01-2003 06:58 PM
Stupid script problems hayduke Mandriva 4 10-03-2003 09:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration