2

i have 2 shell commands and i want to exec in php the first command that act like an application and stay into it and exec another command there (in this application).

i write in my shell: wpa_cli and get the result:

 Interactive mode
    >

now i can write commands in that software, like:

   Interactive mode
    > status

and get the result:

 wpa_state=DISCONNECTED
    p2p_device_address=34:b1:f7:1f:2d:bb
    address=34:b1:f7:1f:2d:bb
    >

my problem is that i want to do that outside the shell by php.

how can i do that?

Cœur
  • 37,241
  • 25
  • 195
  • 267
tamar
  • 41
  • 3

1 Answers1

0

Your requirement is similar to this interactive shell using PHP, but it requires execution of PHP script in terminal, which you don't want.

So, in this case, you can use any of these php functions: shell_exec, exec, system or passthru and run both wpa_cli status commands together, you will get the required result.

e.g. run the following script in your php file and see the output,

echo '<pre>'. shell_exec('wpa_cli status') .'</pre>';

You can also use PHP Ajax Shell or similar scripts to execute your commands and get response on the same page without reloading it.

Community
  • 1
  • 1
Nikhil Supekar
  • 655
  • 6
  • 18