473,774 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ 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 2922
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*******@attgl obal.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*******@attgl obal.net
=============== ===
Jul 17 '05 #10

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

Similar topics

8
1855
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 specified directory and next, clicking on one of them, calling and making an action with an another ASP page. For example: http://server/list.asp Listing Y:\REPOSITORY
8
2944
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: http://www.reloco.com.ar/mozilla/compat.html Bye! PS: I hope it's useful to someone. I would appreciate any comments and suggestions!
7
2074
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 question and tell me where my code is going wrong that I am getting things to load incorrectly. The situation is this: The owner wants "picture pages" that can be printed out exactly as fliers and pages that were created for print years ago. ...
2
1450
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, AppendChild, making width grow? Hi,
5
346
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 like "Show Printable Version". Other than taking out all of the gui stuff and making a simple clean page for printing, is there any other design considerations for making a page good for printing? I'm using frames and all of my content shows in...
19
8109
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 second valid way, but the behaviour is not quite as good (at least not in firefox 1.5), with only the actual text being links. The examples of what I have tried can be found at http://www.bytronic.com/tests/links.html
10
10497
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 are wondering, "Why do I need yet another feature for my big site?" Well, some people can become forgetful every time they see content on your site, and let's suppose that one day they needed to work on a good php script for their class and they...
1
1254
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 over the page. for that i made a new pages with a text box and a ok button. this will come over page and when i enter the new name the that should update the old page. Here I have no idea to create the popup can any body help me. I am new for...
1
1784
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 loaded dynamically (and using a fade effect) into a placeholder div using AJAX. This is all working fine, however the tricky part for me is making the site accessible by using unobtrusive javascript. What I want to do for users with javascript...
0
3561
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 retrieval is unnessecary and makes DataGridView display 2 times slower. How to change this sample code so that only one page is loaded initially and second is loaded on real demand only ? How to change this code so that it allows more than 2...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
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 we have to send another system
3
2852
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.