note 56988 modified in function.exec by danbrown

From: Date: Sun, 04 Jan 2009 16:27:22 +0000
Subject: note 56988 modified in function.exec by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148805@lists.php.net to get a copy of this message
To my way of thinking, it is a good idea to execute programs from the cgi-bin directory of the Web server, to get a little control over configuring a system (at install time, a pointer to the actual program can be symlinked from the cgi-bin directory and the code won't ever have to be changed). If you'd like to do this, under Apache at least, the following should work: <?php if (!($ProgInfo = apache_lookup_uri(/cgi-bin/myprog))) $ProgPath = /usr/bin/myprog; else { if (is_object($ProgInfo)) $ProgPath = $ProgInfo->filename; else $ProgPath = $ProgInfo["filename"]; } exec("$ProgPath ..."); ?> --was-- To my way of thinking, it is a good idea to execute programs from the cgi-bin directory of the Web server, to get a little control over configuring a system (at install time, a pointer to the actual program can be symlinked from the cgi-bin directory and the code won't ever have to be changed). If you'd like to do this, under Apache at least, the following should work: if (!($ProgInfo = apache_lookup_uri(/cgi-bin/myprog))) $ProgPath = /usr/bin/myprog; else { if (is_object($ProgInfo)) $ProgPath = $ProgInfo->filename; else $ProgPath = $ProgInfo["filename"]; } exec("$ProgPath ..."); http://php.net/manual/en/function.exec.php

« previous php.notes (#148805) next »