PHP not reading psexec output

為{幸葍}努か 提交于 2019-12-11 08:20:31

问题


The problem is simple. Running a php file in browser vs command line produces very different results and I can't for the life of me figure out why. Any php/psexec experts out there run into this before?

<?php

echo '<pre>';
$output = shell_exec("psexec -accepteula \\\mypcname -u mypcname\\accountname -p xxxxxxx ipconfig /all 2>&1");
var_dump($output);
echo '</pre>';

Produces this output in a browser window...

string(350) "
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com


Windows IP Configuration

Connecting to admin-pc...


Starting PSEXESVC service on admin-pc...


Connecting with PsExec service on admin-pc...


Starting ipconfig on admin-pc...


ipconfig exited on admin-pc with error code 0.  

Instead of this, which is the output I get when running the same php file via command line.

C:\MAMP\bin\php\php5.5.12>php-cgi c:\mamp\htdocs\go.php
X-Powered-By: PHP/5.5.12
Content-type: text/html

hi<pre>string(5113) "
PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com


Windows IP Configuration

   Host Name . . . . . . . . . . . . : mypcname
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : home

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : home
   Description . . . . . . . . . . . : Intel(R) 82567LM-2 Gigabit Network Connec
   tion
   Physical Address. . . . . . . . . : xx-xx-xx-xx-xx-xx
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.1.4(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Thursday, October 09, 2014 4:36:43 PM
   Lease Expires . . . . . . . . . . : Tuesday, October 14, 2014 4:16:04 PM
   Default Gateway . . . . . . . . . : 192.168.1.1
   DHCP Server . . . . . . . . . . . : 192.168.1.1

   DNS Servers . . . . . . . . . . . : 8.8.8.8
                                       8.8.4.4
   NetBIOS over Tcpip. . . . . . . . : Enabled
"
</pre>
C:\MAMP\bin\php\php5.5.12>

来源:https://stackoverflow.com/questions/26351407/php-not-reading-psexec-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!