简体   繁体   中英

PHP shell_exec Net Use Output

I have the following php command:

  1. $shellOutput = shell_exec('net use');

I receive the following output:

Status  Local   Remote      Network

OK            S:    \\srv\dataS     Microsoft Windows Network

When I run net use in a cmd window I receive the following output

 Status Local   Remote      Network

 OK           L:    \\srv\dataL Microsoft Windows Network
 OK           M:    \\srv\dataM Microsoft Windows Network
 OK           P:    \\srv\dataP Microsoft Windows Network
 OK           R:    \\srv\dataR Microsoft Windows Network
 OK           S:    \\srv\dataS Microsoft Windows Network

Should all the mapped network drives display or does PHP limit the number of drives returned?

If the command supposed to return more than 1 network drive, please provide short example on who to get more than one row to return.

TIA


After performing the var_dump, the value returned was

Status  Local   Remote      Network

OK      S:      \\srv\dataS     Microsoft Windows Network

看起来正在返回最后一行,请使用var_dump($shellOutput)并复制并粘贴结果

After performing the var_dump, the value returned was

Status  Local   Remote      Network

OK      S:      \\srv\dataS     Microsoft Windows Network

shell_execute should return the complete output as a string, please make sure, you are not using exec .

  1. Make sure, the user who is running the code (apache, www-data, httpd,etc) has the right permission for connecting all the network drivers.
  2. Can you please,let me know what are you trying to achieve?

Unfortunately, I do not have a Windows environment, and I can not test Windows commands. However; Linux commands work as expected with shell_exec (output as a string)

Please let me know

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM