Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!not-for-mail From: "M. Strobel" Newsgroups: comp.lang.php Subject: Re: redirect stdout and stderr to PHP variables? Date: Wed, 25 Jan 2012 22:42:36 +0100 Lines: 34 Message-ID: <9obbadF6enU1@mid.uni-berlin.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de dMNU+j5zuGrAceOyml5D8A7dVxrXh+h2BzAsEREvMI5RNlSAw= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.24) Gecko/20111101 Thunderbird/3.1.16 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.php:4612 Am 25.01.2012 20:47, schrieb crankypuss: > I'm sure there's a way to do this, probably some simple syntax I've not= run into and > am too stupid to find in the manual or through google-fu or otherwise. >=20 > I'd like to issue an arbitrary shell command in a subroutine and have i= t return an > array that contains one element representing stdout and another element= representing > stderr. >=20 > For example, using tar to deal with a bazillion files, error messages m= ight not be > seen when specifying verbose output; I'd like to collect them and displ= ay after stdout. >=20 > I've not found any syntax, yet, for redirecting to a PHP variable rathe= r than some file. >=20 > tia. No problem here: php > $res =3D shell_exec('rm this-does-really-not-exist.php 2>&1'); php > echo $res; rm: Entfernen von =E2=80=9Ethis-does-really-not-exist.php=E2=80=9C nicht = m=C3=B6glich: Datei oder Verzeichnis nicht gefunden php > Maybe you drop this requirement "array of...". /Str.