Jump to content

PHP Script enbedded with .cgi


All4172

Recommended Posts

I built a script maybe 6 months ago where I needed to execute a .cgi script inside PHP in order to have it to work on a cron.  The script I have that has worked fine is as follow:

I have a .php script which needs to execute a .cgi with variables after it.  The link looks like this:

[code]
<?PHP
    putenv('QUERY_STRING=login=1&id=admin&pw=admin100&publish_all=1');
    passthru("/home/site/public_html/cgi-bin/exec/admin.cgi");
?>
[/code]

If ran manually you would see its output as:

Set-Cookie: id=admin; Set-Cookie: pw=admin100;

Which is correct.

Now I'm wanting to do same thing with a similar string but am running into problems.  Below is what I have for new script:

[code]
<?PHP    putenv('QUERY_STRING=loginUsername=All&loginPassword=welcome&action=loginSubmit&next&selectedRuleNumbers=11,1,7,9,2,15&nextAction=publishRulesList');
passthru("/home/site/public_html/cgi-bin/script.cgi");
?>
[/code]

If typed in to a browser with above info after the script.cgi, it runs fine. However, this one doesn't seem to work when ran through the php.  It'll give an error message of:

Set-Cookie: username=All
Set-Cookie: passwordHash=CW54Ee2C4v4FU
Location: http://www.site.com/article_list.php?action=loginCookieTest&nextAction=publishUpdated
Content-type: text/html

This page has moved. If you aren't automatically forwarded to the new location then click the following link: http://www.site.com/article_list.php?action=loginCookieTest&nextAction=publishUpdated.

Any ideas on this?
Link to comment
https://forums.phpfreaks.com/topic/29269-php-script-enbedded-with-cgi/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.