473,473 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Making a .php page a .cgi page

I have somebody or some people who are abusing a Perl based .cgi script.
I have written a PHP page which reports this abuse as per
$_SERVER[REMOTE_ADDR]. My intentions were to replace the .cgi script
with this .php script. Problem is these people are coming in with some
web crawler or something like that (i.e. wget
http://myserver.com/thescript.cgi). Now if I replace thescript.cgi with
thescript.php they will not hit it. And if I replace thescript.cgi with
my PHP page, because it's not a Perl script yet ends in .cgi Apache is
saying "Exec format error: exec of '/path/to/script/thescript.cgi'
failed". Is there a way I can configure Apache or otherwise have
thescript.cgi execute PHP code (without crippling other .cgi Perl
scripts on my site)?
--
Why do you always turn down your radio when looking for an address?
Jul 17 '05 #1
9 2907
Andrew DeFaria wrote:
I have somebody or some people who are abusing a Perl based .cgi script.
I have written a PHP page which reports this abuse as per
$_SERVER[REMOTE_ADDR]. My intentions were to replace the .cgi script
with this .php script. Problem is these people are coming in with some
web crawler or something like that (i.e. wget
http://myserver.com/thescript.cgi). Now if I replace thescript.cgi with
thescript.php they will not hit it. And if I replace thescript.cgi with
my PHP page, because it's not a Perl script yet ends in .cgi Apache is
saying "Exec format error: exec of '/path/to/script/thescript.cgi'
failed". Is there a way I can configure Apache or otherwise have
thescript.cgi execute PHP code (without crippling other .cgi Perl
scripts on my site)?


Not really. You could try writing a wee wrapper in Perl to replace
script.cgi which then calls the PHP script - but you won't be able to see
most of the parameters.

C.
Jul 17 '05 #2
Andrew DeFaria <An****@defaria.com> wrote:
And if I replace thescript.cgi with my PHP page, because it's not a
Perl script yet ends in .cgi Apache is saying "Exec format error: exec
of '/path/to/script/thescript.cgi' failed".
Then you are doing something wrong. Extensions have no meaning, it's
just a hint for humans (and that broken browser).
Is there a way I can configure Apache or otherwise have thescript.cgi
execute PHP code (without crippling other .cgi Perl scripts on my
site)?


So a file named foo.cgi with a content like:
#!/usr/bin/php4
<?php
echo "Hello World!";
?>

doesn't work?

Take a look at the Apaches RewriteEngine (mod_rewrite). Alternatively
modify the existing cgi to redirect to the php script.

Jul 17 '05 #3
Andrew DeFaria wrote:
I have somebody or some people who are abusing a Perl based .cgi script.
I have written a PHP page which reports this abuse as per
$_SERVER[REMOTE_ADDR]. My intentions were to replace the .cgi script
with this .php script. Problem is these people are coming in with some
web crawler or something like that (i.e. wget
http://myserver.com/thescript.cgi). Now if I replace thescript.cgi with
thescript.php they will not hit it. And if I replace thescript.cgi with
my PHP page, because it's not a Perl script yet ends in .cgi Apache is
saying "Exec format error: exec of '/path/to/script/thescript.cgi'
failed". Is there a way I can configure Apache or otherwise have
thescript.cgi execute PHP code (without crippling other .cgi Perl
scripts on my site)?


You'll need to tell Apache to parse this file as PHP. I haven't tried
it, but something like this might work in you httpd.conf:

AddType application/x-httpd-php thescript.cgi

If you don't have access to httpd.conf, you probably can add it to your
..htaccess file, but I haven't tried it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #4
Colin McKinnon wrote:
Andrew DeFaria wrote:
I have somebody or some people who are abusing a Perl based .cgi
script.I have written a PHP page which reports this abuse as per
$_SERVER[REMOTE_ADDR]. My intentions were to replace the .cgi script
with this .php script. Problem is these people are coming in with
some web crawler or something like that (i.e. wget
http://myserver.com/thescript.cgi). Now if I replace thescript.cgi
with thescript.php they will not hit it. And if I replace
thescript.cgi with my PHP page, because it's not a Perl script yet
ends in .cgi Apache is saying "Exec format error: exec of
'/path/to/script/thescript.cgi' failed". Is there a way I can
configure Apache or otherwise have thescript.cgi execute PHP code
(without crippling other .cgi Perl scripts on my site)?


Not really. You could try writing a wee wrapper in Perl to replace
script.cgi which then calls the PHP script - but you won't be able to
see most of the parameters.


I was wondering if a simple CGI script that redirects to a similarly
named PHP page would work. I will try that tonight.
--
If I want your opinion, I'll ask you to fill out the necessary forms.

Jul 17 '05 #5
Jerry Stuckle wrote:
Andrew DeFaria wrote:
I have somebody or some people who are abusing a Perl based .cgi
script. I have written a PHP page which reports this abuse as per
$_SERVER[REMOTE_ADDR]. My intentions were to replace the .cgi script
with this .php script. Problem is these people are coming in with
some web crawler or something like that (i.e. wget
http://myserver.com/thescript.cgi). Now if I replace thescript.cgi
with thescript.php they will not hit it. And if I replace
thescript.cgi with my PHP page, because it's not a Perl script yet
ends in .cgi Apache is saying "Exec format error: exec of
'/path/to/script/thescript.cgi' failed". Is there a way I can
configure Apache or otherwise have thescript.cgi execute PHP code
(without crippling other .cgi Perl scripts on my site)?


You'll need to tell Apache to parse this file as PHP. I haven't tried
it, but something like this might work in you httpd.conf:

AddType application/x-httpd-php thescript.cgi

If you don't have access to httpd.conf, you probably can add it to
your .htaccess file, but I haven't tried it.


That would cripple all the other .cgi Perl scripts on my site. I have
configured the CGIType in Apache and normally I want .cgi files to
execute Perl. But in this instance I want the .cgi to be executed by PHP.

I may try a redirect later tonight. Either that or instead of a web page
with embedded PHP I might try the shebang line of #!/usr/bin/php and
have it write out all of the necessary HTML - you know the content
header, etc...
--
It doesn't matter what you do in the bedroom as long as you don't do it
in the street and frighten the horses
Jul 17 '05 #6
Daniel Tryba wrote:
Andrew DeFaria <An****@defaria.com> wrote:
And if I replace thescript.cgi with my PHP page, because it's not a
Perl script yet ends in .cgi Apache is saying "Exec format error:
exec of '/path/to/script/thescript.cgi' failed".
Then you are doing something wrong. Extensions have no meaning, it's
just a hint for humans (and that broken browser).


Extensions have meaning once meaning is assigned. I have configured the
CGI type in Apache. Therefore Apache views all .cgi files a Perl scripts.
Is there a way I can configure Apache or otherwise have thescript.cgi
execute PHP code (without crippling other .cgi Perl scripts on my site)?


So a file named foo.cgi with a content like:
#!/usr/bin/php4
<?php
echo "Hello World!";
?>

doesn't work?


No it doesn't I got "malformed header from script. Bad header=Hello
World!: foo.cgi"
Take a look at the Apaches RewriteEngine (mod_rewrite). Alternatively
modify the existing cgi to redirect to the php script.


I suspect a better approach is to leave .cgi scripts alone and instead
to do a redirect.
--
Why did kamikaze pilots wear helmets?

Jul 17 '05 #7
Andrew DeFaria <An****@defaria.com> wrote:

Please don't post HTML (or any other attachments).
Then you are doing something wrong. Extensions have no meaning, it's
just a hint for humans (and that broken browser).


Extensions have meaning once meaning is assigned. I have configured the
CGI type in Apache. Therefore Apache views all .cgi files a Perl scripts.


A very unfortunate assignment.
Take a look at the Apaches RewriteEngine (mod_rewrite). Alternatively
modify the existing cgi to redirect to the php script.


I suspect a better approach is to leave .cgi scripts alone and instead
to do a redirect.


That is what the RewriteEngine can be used for...

Jul 17 '05 #8
Andrew DeFaria <An****@DeFaria.com> writes:
I have somebody or some people who are abusing a Perl based .cgi
script. I have written a PHP page which reports this abuse as per
$_SERVER[REMOTE_ADDR]. My intentions were to replace the .cgi script
with this .php script. Problem is these people are coming in with some
web crawler or something like that (i.e. wget
http://myserver.com/thescript.cgi). Now if I replace thescript.cgi
with thescript.php they will not hit it. And if I replace
thescript.cgi with my PHP page, because it's not a Perl script yet
ends in .cgi Apache is saying "Exec format error: exec of
'/path/to/script/thescript.cgi' failed". Is there a way I can
configure Apache or otherwise have thescript.cgi execute PHP code
(without crippling other .cgi Perl scripts on my site)?
--
Why do you always turn down your radio when looking for an address?


Use mod_rewrite, it can do what you want (I think)

--Zach
Jul 17 '05 #9
Andrew DeFaria wrote:
Jerry Stuckle wrote:
Andrew DeFaria wrote:
I have somebody or some people who are abusing a Perl based .cgi
script. I have written a PHP page which reports this abuse as per
$_SERVER[REMOTE_ADDR]. My intentions were to replace the .cgi script
with this .php script. Problem is these people are coming in with
some web crawler or something like that (i.e. wget
http://myserver.com/thescript.cgi). Now if I replace thescript.cgi
with thescript.php they will not hit it. And if I replace
thescript.cgi with my PHP page, because it's not a Perl script yet
ends in .cgi Apache is saying "Exec format error: exec of
'/path/to/script/thescript.cgi' failed". Is there a way I can
configure Apache or otherwise have thescript.cgi execute PHP code
(without crippling other .cgi Perl scripts on my site)?

You'll need to tell Apache to parse this file as PHP. I haven't tried
it, but something like this might work in you httpd.conf:

AddType application/x-httpd-php thescript.cgi

If you don't have access to httpd.conf, you probably can add it to
your .htaccess file, but I haven't tried it.

That would cripple all the other .cgi Perl scripts on my site. I have
configured the CGIType in Apache and normally I want .cgi files to
execute Perl. But in this instance I want the .cgi to be executed by PHP.

I may try a redirect later tonight. Either that or instead of a web page
with embedded PHP I might try the shebang line of #!/usr/bin/php and
have it write out all of the necessary HTML - you know the content
header, etc...


Andrew,

No, it will only execute "thescript.cgi". If you put in there "*.cgi"
it would cripple all the other scripts.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: McGrull | last post by:
Sorry for my question, but I'm really a newbie on ASP. I need to make a simple page (for IIS 5.0 and up, but even for 2000 Professional IIS) that read and display the files contained in a...
8
by: Nicolás Lichtmaier | last post by:
Hi, some time ago I've written an article about this issue. It explain some differences in Explorer's and Mozilla's JavaScript/DOM. It has recently changed its URL, This is the new one: ...
7
by: Sens Fan Happy In OH | last post by:
I'm having majour issues with FrontPage 2K and a webpage that I am having to create from scratch based on someone else's prior work. I hope someone can look at the source code for the page in...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
5
by: moondaddy | last post by:
I'm going to use an aspx page to display an invoice that customers can print from. Sometimes when I go to a site and navigate to a page I want to print, they will have a button that says something...
19
by: Martin Eyles | last post by:
Hi, I want to make a whole table a link, so that clicking anywhere on it takes you to another page. Unfortunately the way I initially thought of doing this involved invalid html. I have tried a...
10
Ajm113
by: Ajm113 | last post by:
Making a History Page for BIG Sites Intro: Ok, let's say after a while your website has grown massive. We're talking search engine, forum and video hosting -- you've got a LOT of content. And you...
1
by: amalmraj | last post by:
Dears I making an web page that have a dropdown box and that have some names. also the first item is <New Person>. my need is if i select the <new personthen the new popup window should come...
1
by: nicky77 | last post by:
Hi, apologies in advance is this may be a nonsensical ramble, but I'm hoping someone can give me some advice on how to solve the following problem: I'm developing a site where the main content is...
0
by: Andrus | last post by:
MSDN Winforms DataGridView VirtualMode with caching sample code DataRetriever loads two pages always to cache thus making 2 database accesses. If datagridview uses one page of data, second page...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.