Req #52072 [Opn->Wfx]: RFE: can we have `which`

From: Date: Sun, 13 Jun 2010 00:47:09 +0000
Subject: Req #52072 [Opn->Wfx]: RFE: can we have `which`
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-151407@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52072&edit=1 ID: 52072 Updated by: rasmus@php.net Reported by: php at richardneill dot org Summary: RFE: can we have which -Status: Open +Status: Wont fix Type: Feature/Change Request Package: Filesystem function related Operating System: Linux PHP Version: Irrelevant New Comment: This seems trivial to do in userspace to me: function which($cmd) { $paths = explode(':',$_ENV['PATH']); foreach($paths as $path) { $p = $path.'/'.$cmd; if(file_exists($p)) return $p; } return false; } Previous Comments: ------------------------------------------------------------------------ [2010-06-13 02:34:12] php at richardneill dot org Description: ------------ It would be nice if PHP had a builtin "which" command. For example, which("ffmpeg") would allow the user to check whether ffmpeg was installed, prior to calling it with exec(). Test script: --------------- which("ffmpeg") should return eg: /usr/bin/ffmpeg if the command exists, and is in the £PATH for exec(), or false if it doesn't exist. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52072&edit=1

« previous php.bugs (#151407) next »