note 24031 added to function.system

From: Date: Sun, 04 Aug 2002 19:08:29 +0000
Subject: note 24031 added to function.system
Groups: php.notes 
Request: Send a blank email to php-notes+get-34273@lists.php.net to get a copy of this message
To have system output from both the STDERR and STDOUT, I've modified the function posted above by lowery@craiglowery.com function mysystem($command) { if (!($p=popen("($command)2>&1","r"))) { return 126; } while (!feof($p)) { $line=fgets($p,1000); $out .= $line; } pclose($p); return $out; } Now you can use mysystem() like; $var = "cat ".$file; echo mysystem($var); $catfile = mysystem($var); if (ereg("text", $catfile)) { //stuff here; } N.Jones -- http://www.php.net/manual/en/function.system.php http://master.php.net/manage/user-notes.php?action=edit+24031 http://master.php.net/manage/user-notes.php?action=delete+24031 http://master.php.net/manage/user-notes.php?action=reject+24031

« previous php.notes (#34273) next »