LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 12-07-2005, 01:18 PM   #1
crions
LQ Newbie
 
Registered: May 2005
Location: Home
Distribution: slackware/ubuntu
Posts: 17

Rep: Reputation: 1
exec cmd=perl... work but exec cgi doenst


This HTML entry

<!--#exec cmd="perl /var/www/cgi-bin/count.cgi" -->

works fine!!!

This one:
<!--#exec cgi="/cgi-bin/count.cgi" -->

Does not work and give me those errors at log:

[Wed Dec 7 16:05:51-2005] [error] (2)No such file or directory: exec of /var/www/cgi-bin/count.cgi failed
[Wed Dec 7 16:05:51-2005] [error] [client 192.168.168.101] Premature end of script headers: /var/www/cgi-bin/count.cgi

This is the count.cgi:

#!/usr/local/bin/perl
# Gif images should be named as 0.gif, 1.gif, ..., 9.gif
#

$| = 1;
$image = "pics/counter";
$count = "/var/www/cgi-bin/count.txt";

# Get counter number and increment it
open(COUNT,"$count") || die "Can't open count data file for Reading: $!\n";
$c = <COUNT> ;
close(COUNT);
if ($count =~ /\n$/) {
chop($c);
}
$c++;
open(COUNT,">$count") || die "Can't open count data file for Writing: $!\n";
print COUNT "$c";
close(COUNT);

# Determine counter width
$num = $length = length($c);

# Set Individual Counter Numbers Into Associative Array
while ($num > 0) {
$CHAR{$num} = chop($c);
$num--;
}

# Output gif images to Web server
$j = 1;
print "<img src=$image/0.gif>";
print "<img src=$image/0.gif>";
while ($j <= $length) {
print "<img src=$image/$CHAR{$j}\.gif>";
$j++;
}
________________________________________
Could some one tell me why?????????
 
Old 12-07-2005, 01:23 PM   #2
mago
Member
 
Registered: Apr 2004
Location: Costa Rica
Distribution: slack current with 2.6.16.18 (still off the hook)
Posts: 284

Rep: Reputation: 33
Sound to me that you have a permissions problem, check the httpd.conf to see if the cgi folder has been set correctly and then check if the cgi is executable for the httpd user.
 
Old 12-09-2005, 11:09 AM   #3
crions
LQ Newbie
 
Registered: May 2005
Location: Home
Distribution: slackware/ubuntu
Posts: 17

Original Poster
Rep: Reputation: 1
Forget to mention. Permissions were ok. Problem remains.

If the permissions were not properly set, I would not be
able to run it with <!---#exec cmd="perl....

Is the SAME script.

Tks.
 
Old 12-09-2005, 11:29 AM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Before you write anything back you should include a content-type header:
print "content-type:text/html\n\n";
 
Old 12-09-2005, 11:49 AM   #5
crions
LQ Newbie
 
Registered: May 2005
Location: Home
Distribution: slackware/ubuntu
Posts: 17

Original Poster
Rep: Reputation: 1
Dear friends,

When I type at the prompt:
perl -w count.cgi

it returns:
<img src=pics/counter/0.gif><img src=pics/counter/0.gif><img src=pics/counter/4.gif><img src=pics/counter/2.gif><img src=pics/counter/2.gif><img src=pics/counter/2.gif><img src=pics/counter/7.gif>

AND it is working without the:
print "content-type:text/html\n\n";
WHITIN THE index.html page.

I have included this line BUT THE ERROR REMAINS.

The script is at /var/www/cgi-bin/
All permissions are ok (otherwise it would not run with perl)
It IS WORKING BUT ONLY WITH:
#exec cmd="perl ....."

When I point to the same script with CGI's <--!#exec cgi="...
 
Old 12-09-2005, 12:17 PM   #6
crions
LQ Newbie
 
Registered: May 2005
Location: Home
Distribution: slackware/ubuntu
Posts: 17

Original Poster
Rep: Reputation: 1
Hello folks,

Got it to work:
My first line was WRONG!!!

IT MUST BE #!/usr/bin/perl. (I'm in Slackware)

Sorry for all the trouble and thank you all for the tips!!!
Linux rules.
Merry Xmas and Happy new Year.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cmd that shows which config files are for target exec? oasisbhrnw99 Linux - General 2 09-05-2005 10:58 PM
exec a C prg in a CGI Perl script jagman Linux - Networking 2 05-31-2005 10:40 AM
Exec CGI within a form field newuser455 General 0 09-12-2004 01:50 PM
I Cant Exec a CGI without showing the interpreter. cartridge Linux - Newbie 4 12-19-2003 01:23 PM
exec cgi from php? barazor Programming 5 01-23-2002 09:12 PM


All times are GMT -5. The time now is 01:28 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration