Reply
Best way to include CGI files?
Old 04-30-2008, 03:42 PM Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 201
Is there an easy way to include these things?
Nathand is offline
Reply With Quote
View Public Profile Visit Nathand's homepage!
 
When You Register, These Ads Go Away!
     
Old 05-01-2008, 01:16 AM Re: Best way to include CGI files?
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
CGI is just a standard interfacing protocol for executables usually run from a web server.

Many web servers, including Apache support server side includes (or SSI) The typical format is something like:

<!--#command arg1="value1 arg2="value2 ... -->

And an example from apache.org (v1.3):

<!--#include virtual="/cgi-bin/counter.pl" -->

If you're trying to execute a program from within a PHP script (just guessing since we're in the php forum) then you'll want to use a function such as system() or exec().
__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 09:27 AM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 201
Yes the file is php, so I should use system() or exec()? How do I use these? Do I just stick the file path inside?


Thanks,

Nathan-d
Nathand is offline
Reply With Quote
View Public Profile Visit Nathand's homepage!
 
Old 05-01-2008, 09:50 AM Re: Best way to include CGI files?
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
If you want the program to output directly to the page, use system: http://us.php.net/system

If you need to capture the contents, use exec or the backtick operator:
http://us.php.net/manual/en/function.exec.php
http://us.php.net/manual/en/language....execution.php

__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 08:52 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 201
Unfortunately I can't get this to work. Any other idea's? I've tried both the system("file.php") and passthru("file.php") functions and nothing gets displayed on the page :-(
Nathand is offline
Reply With Quote
View Public Profile Visit Nathand's homepage!
 
Old 05-01-2008, 09:02 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 201
What I really need is for the file to be executed and then the contents dumped out on the screen. Has anyone successfully done this? Can you post working code?

Thanks.
Nathand is offline
Reply With Quote
View Public Profile Visit Nathand's homepage!
 
Old 05-01-2008, 09:41 PM Re: Best way to include CGI files?
addonchat's Avatar
Skilled Talker

Posts: 97
Name: Chris Duerr
Oh, it's just another PHP script you're trying to run? How about just include("file.php") ?
__________________
Chris Duerr
AddonChat Java Chat Software
http://www.addonchat.com/ - Affiliate Program
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 10:26 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 201
Ok, I'm sorry I've been so confusing with my posts.

I need to include PHP, CGI and INC files. The php files try to send header information, that's why I can NOT use the include() function, it generates an error about header information being sent because the header for this page has already been sent.

I also need to include PHP and CGI files.

I still haven't gotten this to work, thanks.
Nathand is offline
Reply With Quote
View Public Profile Visit Nathand's homepage!
 
Old 05-02-2008, 10:34 AM Re: Best way to include CGI files?
nickohrn's Avatar
Weightlifting CS Student

Posts: 505
Name: Nick Ohrn
Nathand, if you're worried about header information already being sent, you can use an output buffer to control when and where the headers are sent to the browser.

Do you have control over the PHP files that are being included? Why not just remove the header information from them. Also, what kind of CGI files are you trying to include?

PHP's Output Control Functions
__________________
Plugin-Developer.com - Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
nickohrn is offline
Reply With Quote
View Public Profile Visit nickohrn's homepage!
 
Old 05-02-2008, 01:45 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 201
While the php files are on the server, I don't have permission to edit them. Is there any way to just have them execute as a separate page and then echo the contents?

There are several different CGI files being included, they all look like this "/cgi-bin/vote/vcenter-ssi.cgi".
Nathand is offline
Reply With Quote
View Public Profile Visit Nathand's homepage!
 
Old 05-02-2008, 01:51 PM Re: Best way to include CGI files?
nickohrn's Avatar
Weightlifting CS Student

Posts: 505
Name: Nick Ohrn
I suppose you could try this to execute them as a separate page and just grab the contents.

PHP Code:
if( function_exists'curl_init' ) ) {
            
                
// Start the cURL session
                
$session curl_init$address_of_page );
                
                
// Set some cURL options
                
curl_setopt$sessionCURLOPT_HEADERfalse );
                
curl_setopt$sessionCURLOPT_RETURNTRANSFERtrue );
                
                
// Execute the cURL request
                // The contents of the page are now stored in $response
                
$response curl_exec$session );
                
                
// Close the cURL connection
                
curl_close$session );
            
            } 
__________________
Plugin-Developer.com - Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
nickohrn is offline
Reply With Quote
View Public Profile Visit nickohrn's homepage!
 
Reply     « Reply to Best way to include CGI files?
 

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15293 seconds with 13 queries