Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 233
Location: USA
Trades: 0
Is there an easy way to include these things?
Nathand is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-01-2008, 02:16 AM Re: Best way to include CGI files?
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
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

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 10:27 AM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
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
 
Old 05-01-2008, 10:50 AM Re: Best way to include CGI files?
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
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

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 09:52 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
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
 
Old 05-01-2008, 10:02 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
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
 
Old 05-01-2008, 10:41 PM Re: Best way to include CGI files?
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
Oh, it's just another PHP script you're trying to run? How about just include("file.php") ?
__________________
Chris Duerr
AddonChat Java Chat Software

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 11:26 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
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
 
Old 05-02-2008, 11:34 AM Re: Best way to include CGI files?
Plugin-Developer's Avatar
Weightlifting CS Student

Posts: 504
Name: Nick Ohrn
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
- Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
Plugin-Developer is offline
Reply With Quote
View Public Profile Visit Plugin-Developer's homepage!
 
Old 05-02-2008, 02:45 PM Re: Best way to include CGI files?
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
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
 
Old 05-02-2008, 02:51 PM Re: Best way to include CGI files?
Plugin-Developer's Avatar
Weightlifting CS Student

Posts: 504
Name: Nick Ohrn
Trades: 0
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 );
            
            } 
__________________

Please login or register to view this content. Registration is FREE
- Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
Plugin-Developer is offline
Reply With Quote
View Public Profile Visit Plugin-Developer's homepage!
 
Reply     « Reply to Best way to include CGI files?
 

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 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.66667 seconds with 12 queries